@wordpress/edit-site 5.29.0 → 5.31.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/actions/index.js +3 -5
- package/build/components/actions/index.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +18 -6
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +1 -1
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/editor/index.js +1 -15
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/font-families.js +1 -1
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-library-modal/collection-font-variant.js +2 -2
- package/build/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +70 -59
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-card.js +10 -15
- package/build/components/global-styles/font-library-modal/font-card.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +121 -78
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-demo.js +29 -8
- package/build/components/global-styles/font-library-modal/font-demo.js.map +1 -1
- package/build/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +3 -2
- package/build/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +19 -6
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +151 -79
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/library-font-variant.js +2 -2
- package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build/components/global-styles/font-library-modal/upload-fonts.js +51 -23
- package/build/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/index.js +39 -5
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js +4 -1
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/header.js +2 -2
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/highlighted-colors.js +50 -0
- package/build/components/global-styles/highlighted-colors.js.map +1 -0
- package/build/components/global-styles/hooks.js +50 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/preview-colors.js +62 -0
- package/build/components/global-styles/preview-colors.js.map +1 -0
- package/build/components/global-styles/preview-iframe.js +130 -0
- package/build/components/global-styles/preview-iframe.js.map +1 -0
- package/build/components/global-styles/preview-styles.js +163 -0
- package/build/components/global-styles/preview-styles.js.map +1 -0
- package/build/components/global-styles/screen-block-list.js +1 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-block.js +1 -1
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +3 -2
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +2 -2
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-root.js +2 -2
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +5 -2
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +12 -84
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/{typogrphy-elements.js → typography-elements.js} +4 -2
- package/build/components/global-styles/typography-elements.js.map +1 -0
- package/build/components/global-styles/typography-example.js +67 -0
- package/build/components/global-styles/typography-example.js.map +1 -0
- package/build/components/global-styles/typography-preview.js +3 -1
- package/build/components/global-styles/typography-preview.js.map +1 -1
- package/build/components/global-styles/ui.js +27 -2
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/utils.js +22 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/global-styles/variations/variation.js +90 -0
- package/build/components/global-styles/variations/variation.js.map +1 -0
- package/build/components/global-styles/variations/variations-color.js +35 -0
- package/build/components/global-styles/variations/variations-color.js.map +1 -0
- package/build/components/global-styles/{variations-panel.js → variations/variations-panel.js} +1 -1
- package/build/components/global-styles/variations/variations-panel.js.map +1 -0
- package/build/components/global-styles/variations/variations-typography.js +54 -0
- package/build/components/global-styles/variations/variations-typography.js.map +1 -0
- package/build/components/header-edit-mode/index.js +14 -12
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +10 -2
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +6 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcuts/global.js +17 -3
- package/build/components/keyboard-shortcuts/global.js.map +1 -1
- package/build/components/layout/index.js +4 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/router.js +2 -5
- package/build/components/layout/router.js.map +1 -1
- package/build/components/page-pages/index.js +6 -11
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/delete-category-menu-item.js +6 -1
- package/build/components/page-patterns/delete-category-menu-item.js.map +1 -1
- package/build/components/page-patterns/index.js +15 -18
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +9 -9
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/{list/added-by.js → page-templates-template-parts/hooks.js} +1 -61
- package/build/components/page-templates-template-parts/hooks.js.map +1 -0
- package/build/components/page-templates-template-parts/index.js +25 -22
- package/build/components/page-templates-template-parts/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +2 -1
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/revisions/index.js.map +1 -1
- package/build/components/save-panel/index.js +31 -11
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +3 -4
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-dataviews/custom-dataviews-list.js +2 -2
- package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build/components/sidebar-dataviews/dataview-item.js +2 -2
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +4 -2
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +4 -3
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/index.js +2 -2
- package/build/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js +3 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build/components/sidebar-edit-mode/sidebar-card/index.js +12 -6
- package/build/components/sidebar-edit-mode/sidebar-card/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/index.js +23 -3
- package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +13 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +1 -2
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/{delete-modal.js → delete-confirm-dialog.js} +4 -5
- package/build/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js +6 -6
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +0 -3
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +2 -2
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/index.js +7 -3
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/content.js +6 -6
- package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +7 -5
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +1 -1
- 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-path-with-url.js +1 -11
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-actions/index.js +44 -27
- package/build/components/template-actions/index.js.map +1 -1
- package/build/components/welcome-guide/editor.js +11 -2
- package/build/components/welcome-guide/editor.js.map +1 -1
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +78 -0
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build/utils/constants.js +5 -3
- package/build/utils/constants.js.map +1 -1
- package/build/utils/get-is-list-page.js +1 -1
- package/build/utils/get-is-list-page.js.map +1 -1
- package/build/utils/math.js +98 -0
- package/build/utils/math.js.map +1 -0
- package/build-module/components/actions/index.js +4 -6
- package/build-module/components/actions/index.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +18 -6
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/editor/index.js +2 -16
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +1 -1
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js +4 -4
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +72 -61
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-card.js +11 -16
- package/build-module/components/global-styles/font-library-modal/font-card.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +124 -81
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-demo.js +30 -9
- package/build-module/components/global-styles/font-library-modal/font-demo.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +4 -3
- package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +19 -6
- package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +151 -79
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js +4 -4
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js +52 -24
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/index.js +38 -5
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js +4 -1
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/header.js +2 -2
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/highlighted-colors.js +43 -0
- package/build-module/components/global-styles/highlighted-colors.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +48 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/preview-colors.js +54 -0
- package/build-module/components/global-styles/preview-colors.js.map +1 -0
- package/build-module/components/global-styles/preview-iframe.js +123 -0
- package/build-module/components/global-styles/preview-iframe.js.map +1 -0
- package/build-module/components/global-styles/preview-styles.js +155 -0
- package/build-module/components/global-styles/preview-styles.js.map +1 -0
- package/build-module/components/global-styles/screen-block-list.js +1 -1
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +1 -1
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +3 -2
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +2 -2
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +2 -2
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +5 -2
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +13 -85
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/{typogrphy-elements.js → typography-elements.js} +4 -2
- package/build-module/components/global-styles/typography-elements.js.map +1 -0
- package/build-module/components/global-styles/typography-example.js +60 -0
- package/build-module/components/global-styles/typography-example.js.map +1 -0
- package/build-module/components/global-styles/typography-preview.js +3 -1
- package/build-module/components/global-styles/typography-preview.js.map +1 -1
- package/build-module/components/global-styles/ui.js +27 -2
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/utils.js +21 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/global-styles/variations/variation.js +82 -0
- package/build-module/components/global-styles/variations/variation.js.map +1 -0
- package/build-module/components/global-styles/variations/variations-color.js +27 -0
- package/build-module/components/global-styles/variations/variations-color.js.map +1 -0
- package/build-module/components/global-styles/{variations-panel.js → variations/variations-panel.js} +1 -1
- package/build-module/components/global-styles/variations/variations-panel.js.map +1 -0
- package/build-module/components/global-styles/variations/variations-typography.js +46 -0
- package/build-module/components/global-styles/variations/variations-typography.js.map +1 -0
- package/build-module/components/header-edit-mode/index.js +15 -13
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +13 -5
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +6 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/global.js +17 -3
- package/build-module/components/keyboard-shortcuts/global.js.map +1 -1
- package/build-module/components/layout/index.js +4 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/router.js +2 -5
- package/build-module/components/layout/router.js.map +1 -1
- package/build-module/components/page-pages/index.js +7 -12
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/delete-category-menu-item.js +6 -1
- package/build-module/components/page-patterns/delete-category-menu-item.js.map +1 -1
- package/build-module/components/page-patterns/index.js +16 -19
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +9 -9
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/{list/added-by.js → page-templates-template-parts/hooks.js} +2 -59
- package/build-module/components/page-templates-template-parts/hooks.js.map +1 -0
- package/build-module/components/page-templates-template-parts/index.js +25 -22
- package/build-module/components/page-templates-template-parts/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +2 -1
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/revisions/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +31 -11
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -4
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +2 -2
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build-module/components/sidebar-dataviews/dataview-item.js +2 -2
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +6 -4
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +4 -3
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/index.js +3 -3
- package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js +4 -2
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/sidebar-card/index.js +13 -7
- package/build-module/components/sidebar-edit-mode/sidebar-card/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/index.js +24 -4
- package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +14 -2
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +1 -2
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/{delete-modal.js → delete-confirm-dialog.js} +3 -4
- package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js +6 -6
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +0 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js +6 -2
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +5 -5
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -5
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +1 -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-path-with-url.js +1 -11
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/template-actions/index.js +44 -27
- package/build-module/components/template-actions/index.js.map +1 -1
- package/build-module/components/welcome-guide/editor.js +11 -2
- package/build-module/components/welcome-guide/editor.js.map +1 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +76 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/utils/constants.js +4 -2
- package/build-module/utils/constants.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +1 -1
- package/build-module/utils/get-is-list-page.js.map +1 -1
- package/build-module/utils/math.js +92 -0
- package/build-module/utils/math.js.map +1 -0
- package/build-style/style-rtl.css +196 -315
- package/build-style/style.css +196 -315
- package/package.json +42 -42
- package/src/components/actions/index.js +4 -6
- package/src/components/block-editor/editor-canvas.js +20 -6
- package/src/components/block-editor/style.scss +0 -3
- package/src/components/block-editor/use-site-editor-settings.js +0 -2
- package/src/components/editor/index.js +0 -20
- package/src/components/global-styles/color-palette-panel.js +0 -1
- package/src/components/global-styles/font-families.js +1 -1
- package/src/components/global-styles/font-library-modal/collection-font-variant.js +5 -5
- package/src/components/global-styles/font-library-modal/context.js +136 -107
- package/src/components/global-styles/font-library-modal/font-card.js +11 -26
- package/src/components/global-styles/font-library-modal/font-collection.js +298 -218
- package/src/components/global-styles/font-library-modal/font-demo.js +38 -4
- package/src/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +9 -2
- package/src/components/global-styles/font-library-modal/index.js +23 -16
- package/src/components/global-styles/font-library-modal/installed-fonts.js +243 -114
- package/src/components/global-styles/font-library-modal/library-font-variant.js +5 -5
- package/src/components/global-styles/font-library-modal/style.scss +27 -11
- package/src/components/global-styles/font-library-modal/upload-fonts.js +70 -27
- package/src/components/global-styles/font-library-modal/utils/index.js +45 -5
- package/src/components/global-styles/font-library-modal/utils/preview-styles.js +6 -1
- package/src/components/global-styles/font-library-modal/utils/test/getDisplaySrcFromFontFace.spec.js +7 -18
- package/src/components/global-styles/gradients-palette-panel.js +2 -2
- package/src/components/global-styles/header.js +2 -2
- package/src/components/global-styles/highlighted-colors.js +39 -0
- package/src/components/global-styles/hooks.js +68 -1
- package/src/components/global-styles/preview-colors.js +61 -0
- package/src/components/global-styles/preview-iframe.js +152 -0
- package/src/components/global-styles/preview-styles.js +185 -0
- package/src/components/global-styles/screen-block-list.js +1 -1
- package/src/components/global-styles/screen-block.js +4 -1
- package/src/components/global-styles/screen-colors.js +3 -2
- package/src/components/global-styles/screen-revisions/index.js +5 -2
- package/src/components/global-styles/screen-root.js +2 -2
- package/src/components/global-styles/screen-typography.js +8 -2
- package/src/components/global-styles/style-variations-container.js +14 -92
- package/src/components/global-styles/style.scss +4 -35
- package/src/components/global-styles/{typogrphy-elements.js → typography-elements.js} +5 -1
- package/src/components/global-styles/typography-example.js +64 -0
- package/src/components/global-styles/typography-preview.js +3 -1
- package/src/components/global-styles/ui.js +26 -2
- package/src/components/global-styles/utils.js +37 -0
- package/src/components/global-styles/variations/style.scss +38 -0
- package/src/components/global-styles/variations/variation.js +93 -0
- package/src/components/global-styles/variations/variations-color.js +34 -0
- package/src/components/global-styles/{variations-panel.js → variations/variations-panel.js} +1 -1
- package/src/components/global-styles/variations/variations-typography.js +63 -0
- package/src/components/header-edit-mode/index.js +21 -27
- package/src/components/header-edit-mode/more-menu/index.js +17 -8
- package/src/components/header-edit-mode/style.scss +4 -0
- package/src/components/keyboard-shortcut-help-modal/config.js +4 -0
- package/src/components/keyboard-shortcuts/global.js +16 -4
- package/src/components/layout/index.js +5 -0
- package/src/components/layout/router.js +2 -7
- package/src/components/page-pages/index.js +8 -13
- package/src/components/page-patterns/delete-category-menu-item.js +7 -0
- package/src/components/page-patterns/index.js +23 -24
- package/src/components/page-patterns/use-patterns.js +17 -10
- package/src/components/{list/added-by.js → page-templates-template-parts/hooks.js} +1 -66
- package/src/components/page-templates-template-parts/index.js +34 -25
- package/src/components/page-templates-template-parts/style.scss +48 -0
- package/src/components/resizable-frame/index.js +1 -0
- package/src/components/revisions/index.js +1 -1
- package/src/components/save-panel/index.js +56 -27
- package/src/components/sidebar/index.js +3 -4
- package/src/components/sidebar-dataviews/custom-dataviews-list.js +2 -2
- package/src/components/sidebar-dataviews/dataview-item.js +2 -2
- package/src/components/sidebar-dataviews/default-views.js +14 -4
- package/src/components/sidebar-dataviews/index.js +4 -3
- package/src/components/sidebar-edit-mode/page-panels/index.js +2 -2
- package/src/components/sidebar-edit-mode/page-panels/page-status.js +1 -1
- package/src/components/sidebar-edit-mode/page-panels/page-summary.js +2 -0
- package/src/components/sidebar-edit-mode/sidebar-card/index.js +30 -11
- package/src/components/sidebar-edit-mode/sidebar-card/style.scss +10 -11
- package/src/components/sidebar-edit-mode/template-panel/index.js +25 -6
- package/src/components/sidebar-navigation-screen/style.scss +10 -1
- package/src/components/sidebar-navigation-screen-global-styles/index.js +35 -2
- package/src/components/sidebar-navigation-screen-main/index.js +0 -2
- package/src/components/sidebar-navigation-screen-navigation-menu/{delete-modal.js → delete-confirm-dialog.js} +3 -4
- package/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js +11 -9
- package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +0 -2
- package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +6 -3
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +1 -1
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +1 -1
- package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +1 -1
- package/src/components/sidebar-navigation-screen-template/index.js +7 -2
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +5 -5
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +5 -3
- package/src/components/start-template-options/index.js +1 -1
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +1 -1
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +3 -19
- package/src/components/template-actions/index.js +63 -46
- package/src/components/welcome-guide/editor.js +9 -6
- package/src/hooks/use-theme-style-variations/test/use-theme-style-variations-by-property.js +173 -0
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +85 -1
- package/src/style.scss +2 -3
- package/src/utils/constants.js +4 -2
- package/src/utils/get-is-list-page.js +1 -1
- package/src/utils/math.js +93 -0
- package/build/components/global-styles/font-library-modal/collection-font-details.js +0 -50
- package/build/components/global-styles/font-library-modal/collection-font-details.js.map +0 -1
- package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -30
- package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +0 -1
- package/build/components/global-styles/font-library-modal/library-font-card.js +0 -39
- package/build/components/global-styles/font-library-modal/library-font-card.js.map +0 -1
- package/build/components/global-styles/font-library-modal/tab-panel-layout.js +0 -67
- package/build/components/global-styles/font-library-modal/tab-panel-layout.js.map +0 -1
- package/build/components/global-styles/preview.js +0 -271
- package/build/components/global-styles/preview.js.map +0 -1
- package/build/components/global-styles/typogrphy-elements.js.map +0 -1
- package/build/components/global-styles/variations-panel.js.map +0 -1
- package/build/components/list/added-by.js.map +0 -1
- package/build/components/list/header.js +0 -55
- package/build/components/list/header.js.map +0 -1
- package/build/components/list/index.js +0 -80
- package/build/components/list/index.js.map +0 -1
- package/build/components/list/table.js +0 -94
- package/build/components/list/table.js.map +0 -1
- package/build/components/list/use-register-shortcuts.js +0 -51
- package/build/components/list/use-register-shortcuts.js.map +0 -1
- package/build/components/sidebar-edit-mode/template-panel/template-actions.js +0 -50
- package/build/components/sidebar-edit-mode/template-panel/template-actions.js.map +0 -1
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js +0 -36
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js.map +0 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/delete-modal.js.map +0 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js +0 -36
- package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +0 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +0 -132
- package/build/components/sidebar-navigation-screen-templates/index.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/collection-font-details.js +0 -42
- package/build-module/components/global-styles/font-library-modal/collection-font-details.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -23
- package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/library-font-card.js +0 -31
- package/build-module/components/global-styles/font-library-modal/library-font-card.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js +0 -60
- package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js.map +0 -1
- package/build-module/components/global-styles/preview.js +0 -264
- package/build-module/components/global-styles/preview.js.map +0 -1
- package/build-module/components/global-styles/typogrphy-elements.js.map +0 -1
- package/build-module/components/global-styles/variations-panel.js.map +0 -1
- package/build-module/components/list/added-by.js.map +0 -1
- package/build-module/components/list/header.js +0 -47
- package/build-module/components/list/header.js.map +0 -1
- package/build-module/components/list/index.js +0 -72
- package/build-module/components/list/index.js.map +0 -1
- package/build-module/components/list/table.js +0 -86
- package/build-module/components/list/table.js.map +0 -1
- package/build-module/components/list/use-register-shortcuts.js +0 -45
- package/build-module/components/list/use-register-shortcuts.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/template-panel/template-actions.js +0 -42
- package/build-module/components/sidebar-edit-mode/template-panel/template-actions.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js +0 -29
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-modal.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js +0 -27
- package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +0 -124
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +0 -1
- package/src/components/global-styles/font-library-modal/collection-font-details.js +0 -56
- package/src/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -33
- package/src/components/global-styles/font-library-modal/library-font-card.js +0 -34
- package/src/components/global-styles/font-library-modal/tab-panel-layout.js +0 -85
- package/src/components/global-styles/preview.js +0 -327
- package/src/components/list/header.js +0 -48
- package/src/components/list/index.js +0 -87
- package/src/components/list/style.scss +0 -188
- package/src/components/list/table.js +0 -140
- package/src/components/list/use-register-shortcuts.js +0 -49
- package/src/components/sidebar-edit-mode/template-panel/template-actions.js +0 -49
- package/src/components/sidebar-navigation-screen-main/template-part-hint.js +0 -34
- package/src/components/sidebar-navigation-screen-navigation-menu/edit-button.js +0 -22
- package/src/components/sidebar-navigation-screen-templates/index.js +0 -156
- package/src/components/sidebar-navigation-screen-templates/style.scss +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useState","useEffect","privateApis","blockEditorPrivateApis","useSelect","useDispatch","useEntityRecord","useEntityRecords","store","coreStore","__","sprintf","fetchGetFontFamilyBySlug","fetchInstallFontFamily","fetchUninstallFontFamily","fetchFontCollections","fetchFontCollection","unlock","useGlobalSetting","setUIValuesNeeded","mergeFontFamilies","loadFontFaceInBrowser","getDisplaySrcFromFontFace","makeFontFacesFormData","makeFontFamilyFormData","batchInstallFontFaces","checkFontFaceInstalled","toggleFont","FontLibraryContext","FontLibraryProvider","children","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","globalStylesId","select","__experimentalGetCurrentGlobalStylesId","globalStyles","fontFamiliesHasChanges","edits","settings","typography","fontFamilies","isInstalling","setIsInstalling","refreshKey","setRefreshKey","notice","setNotice","refreshLibrary","Date","now","records","libraryPosts","isResolving","isResolvingLibrary","hasResolved","hasResolvedLibrary","_embed","libraryFonts","map","fontFamilyPost","id","font_family_settings","fontFace","_embedded","font_faces","face","font_face_settings","setFontFamilies","baseFontFamilies","undefined","saveFontFamilies","modalTabOpen","setModalTabOpen","libraryFontSelected","setLibraryFontSelected","baseThemeFonts","theme","f","source","sort","a","b","name","localeCompare","themeFonts","customFonts","custom","baseCustomFonts","handleSetLibraryFontSelected","font","fonts","fontSelected","find","slug","toggleModal","tabName","loadedFontUrls","Set","site","currentTheme","getSite","getCurrentTheme","themeUrl","url","stylesheet","getAvailableFontsOutline","availableFontFamilies","outline","reduce","acc","availableFontFaces","length","fontStyle","fontWeight","getActivatedFontsOutline","isFontActivated","style","weight","includes","getFontFacesActivated","installFont","fontFamilyToInstall","installedFontFamily","alreadyInstalledFontFaces","filter","fontFaceToInstall","sucessfullyInstalledFontFaces","unsucessfullyInstalledFontFaces","response","successes","errors","detailedErrorMessage","errorMessageCollection","error","message","Error","activateCustomFontFamilies","uninstallFontFamily","fontFamilyToUninstall","uninstalledFontFamily","deleted","deactivateFontFamily","console","_fontFamilies$font$so","initialCustomFonts","newCustomFonts","fontsToAdd","forEach","src","toggleActivateFont","_fontFamilies$font$so2","initialFonts","newFonts","loadFontFaceAsset","has","add","collections","setFontCollections","getFontCollections","getFontCollection","hasData","collection","font_families","updatedCollections","e","createElement","Provider","value"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useState, useEffect } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseEntityRecord,\n\tuseEntityRecords,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tfetchGetFontFamilyBySlug,\n\tfetchInstallFontFamily,\n\tfetchUninstallFontFamily,\n\tfetchFontCollections,\n\tfetchFontCollection,\n} from './resolvers';\nimport { unlock } from '../../../lock-unlock';\nconst { useGlobalSetting } = unlock( blockEditorPrivateApis );\nimport {\n\tsetUIValuesNeeded,\n\tmergeFontFamilies,\n\tloadFontFaceInBrowser,\n\tgetDisplaySrcFromFontFace,\n\tmakeFontFacesFormData,\n\tmakeFontFamilyFormData,\n\tbatchInstallFontFaces,\n\tcheckFontFaceInstalled,\n} from './utils';\nimport { toggleFont } from './utils/toggleFont';\n\nexport const FontLibraryContext = createContext( {} );\n\nfunction FontLibraryProvider( { children } ) {\n\tconst { __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits } =\n\t\tuseDispatch( coreStore );\n\tconst { globalStylesId } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetCurrentGlobalStylesId } = select( coreStore );\n\t\treturn { globalStylesId: __experimentalGetCurrentGlobalStylesId() };\n\t} );\n\n\tconst globalStyles = useEntityRecord(\n\t\t'root',\n\t\t'globalStyles',\n\t\tglobalStylesId\n\t);\n\tconst fontFamiliesHasChanges =\n\t\t!! globalStyles?.edits?.settings?.typography?.fontFamilies;\n\n\tconst [ isInstalling, setIsInstalling ] = useState( false );\n\tconst [ refreshKey, setRefreshKey ] = useState( 0 );\n\tconst [ notice, setNotice ] = useState( null );\n\n\tconst refreshLibrary = () => {\n\t\tsetRefreshKey( Date.now() );\n\t};\n\n\tconst {\n\t\trecords: libraryPosts = [],\n\t\tisResolving: isResolvingLibrary,\n\t\thasResolved: hasResolvedLibrary,\n\t} = useEntityRecords( 'postType', 'wp_font_family', {\n\t\trefreshKey,\n\t\t_embed: true,\n\t} );\n\n\tconst libraryFonts =\n\t\t( libraryPosts || [] ).map( ( fontFamilyPost ) => {\n\t\t\treturn {\n\t\t\t\tid: fontFamilyPost.id,\n\t\t\t\t...fontFamilyPost.font_family_settings,\n\t\t\t\tfontFace:\n\t\t\t\t\tfontFamilyPost?._embedded?.font_faces.map(\n\t\t\t\t\t\t( face ) => face.font_face_settings\n\t\t\t\t\t) || [],\n\t\t\t};\n\t\t} ) || [];\n\n\t// Global Styles (settings) font families\n\tconst [ fontFamilies, setFontFamilies ] = useGlobalSetting(\n\t\t'typography.fontFamilies'\n\t);\n\t// theme.json file font families\n\tconst [ baseFontFamilies ] = useGlobalSetting(\n\t\t'typography.fontFamilies',\n\t\tundefined,\n\t\t'base'\n\t);\n\n\t// Save font families to the global styles post in the database.\n\tconst saveFontFamilies = () => {\n\t\tsaveSpecifiedEntityEdits( 'root', 'globalStyles', globalStylesId, [\n\t\t\t'settings.typography.fontFamilies',\n\t\t] );\n\t};\n\n\t// Library Fonts\n\tconst [ modalTabOpen, setModalTabOpen ] = useState( false );\n\tconst [ libraryFontSelected, setLibraryFontSelected ] = useState( null );\n\n\tconst baseThemeFonts = baseFontFamilies?.theme\n\t\t? baseFontFamilies.theme\n\t\t\t\t.map( ( f ) => setUIValuesNeeded( f, { source: 'theme' } ) )\n\t\t\t\t.sort( ( a, b ) => a.name.localeCompare( b.name ) )\n\t\t: [];\n\n\tconst themeFonts = fontFamilies?.theme\n\t\t? fontFamilies.theme\n\t\t\t\t.map( ( f ) => setUIValuesNeeded( f, { source: 'theme' } ) )\n\t\t\t\t.sort( ( a, b ) => a.name.localeCompare( b.name ) )\n\t\t: [];\n\n\tconst customFonts = fontFamilies?.custom\n\t\t? fontFamilies.custom\n\t\t\t\t.map( ( f ) => setUIValuesNeeded( f, { source: 'custom' } ) )\n\t\t\t\t.sort( ( a, b ) => a.name.localeCompare( b.name ) )\n\t\t: [];\n\n\tconst baseCustomFonts = libraryFonts\n\t\t? libraryFonts\n\t\t\t\t.map( ( f ) => setUIValuesNeeded( f, { source: 'custom' } ) )\n\t\t\t\t.sort( ( a, b ) => a.name.localeCompare( b.name ) )\n\t\t: [];\n\n\tuseEffect( () => {\n\t\tif ( ! modalTabOpen ) {\n\t\t\tsetLibraryFontSelected( null );\n\t\t}\n\t}, [ modalTabOpen ] );\n\n\tconst handleSetLibraryFontSelected = ( font ) => {\n\t\tsetNotice( null );\n\n\t\t// If font is null, reset the selected font\n\t\tif ( ! font ) {\n\t\t\tsetLibraryFontSelected( null );\n\t\t\treturn;\n\t\t}\n\n\t\tconst fonts =\n\t\t\tfont.source === 'theme' ? baseThemeFonts : baseCustomFonts;\n\n\t\t// Tries to find the font in the installed fonts\n\t\tconst fontSelected = fonts.find( ( f ) => f.slug === font.slug );\n\t\t// If the font is not found (it is only defined in custom styles), use the font from custom styles\n\t\tsetLibraryFontSelected( {\n\t\t\t...( fontSelected || font ),\n\t\t\tsource: font.source,\n\t\t} );\n\t};\n\n\tconst toggleModal = ( tabName ) => {\n\t\tsetModalTabOpen( tabName || null );\n\t};\n\n\t// Demo\n\tconst [ loadedFontUrls ] = useState( new Set() );\n\n\t// Theme data\n\tconst { site, currentTheme } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tsite: select( coreStore ).getSite(),\n\t\t\tcurrentTheme: select( coreStore ).getCurrentTheme(),\n\t\t};\n\t} );\n\tconst themeUrl =\n\t\tsite?.url + '/wp-content/themes/' + currentTheme?.stylesheet;\n\n\tconst getAvailableFontsOutline = ( availableFontFamilies ) => {\n\t\tconst outline = availableFontFamilies.reduce( ( acc, font ) => {\n\t\t\tconst availableFontFaces =\n\t\t\t\tfont?.fontFace && font.fontFace?.length > 0\n\t\t\t\t\t? font?.fontFace.map(\n\t\t\t\t\t\t\t( face ) => `${ face.fontStyle + face.fontWeight }`\n\t\t\t\t\t )\n\t\t\t\t\t: [ 'normal400' ]; // If the font doesn't have fontFace, we assume it is a system font and we add the defaults: normal 400\n\n\t\t\tacc[ font.slug ] = availableFontFaces;\n\t\t\treturn acc;\n\t\t}, {} );\n\t\treturn outline;\n\t};\n\n\tconst getActivatedFontsOutline = ( source ) => {\n\t\tswitch ( source ) {\n\t\t\tcase 'theme':\n\t\t\t\treturn getAvailableFontsOutline( themeFonts );\n\t\t\tcase 'custom':\n\t\t\tdefault:\n\t\t\t\treturn getAvailableFontsOutline( customFonts );\n\t\t}\n\t};\n\n\tconst isFontActivated = ( slug, style, weight, source ) => {\n\t\tif ( ! style && ! weight ) {\n\t\t\treturn !! getActivatedFontsOutline( source )[ slug ];\n\t\t}\n\t\treturn !! getActivatedFontsOutline( source )[ slug ]?.includes(\n\t\t\tstyle + weight\n\t\t);\n\t};\n\n\tconst getFontFacesActivated = ( slug, source ) => {\n\t\treturn getActivatedFontsOutline( source )[ slug ] || [];\n\t};\n\n\tasync function installFont( fontFamilyToInstall ) {\n\t\tsetIsInstalling( true );\n\t\ttry {\n\t\t\t// Get the font family if it already exists.\n\t\t\tlet installedFontFamily = await fetchGetFontFamilyBySlug(\n\t\t\t\tfontFamilyToInstall.slug\n\t\t\t);\n\n\t\t\t// Otherwise create it.\n\t\t\tif ( ! installedFontFamily ) {\n\t\t\t\t// Prepare font family form data to install.\n\t\t\t\tinstalledFontFamily = await fetchInstallFontFamily(\n\t\t\t\t\tmakeFontFamilyFormData( fontFamilyToInstall )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Collect font faces that have already been installed (to be activated later)\n\t\t\tconst alreadyInstalledFontFaces =\n\t\t\t\tinstalledFontFamily.fontFace && fontFamilyToInstall.fontFace\n\t\t\t\t\t? installedFontFamily.fontFace.filter(\n\t\t\t\t\t\t\t( fontFaceToInstall ) =>\n\t\t\t\t\t\t\t\tcheckFontFaceInstalled(\n\t\t\t\t\t\t\t\t\tfontFaceToInstall,\n\t\t\t\t\t\t\t\t\tfontFamilyToInstall.fontFace\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t )\n\t\t\t\t\t: [];\n\n\t\t\t// Filter out Font Faces that have already been installed (so that they are not re-installed)\n\t\t\tif (\n\t\t\t\tinstalledFontFamily.fontFace &&\n\t\t\t\tfontFamilyToInstall.fontFace\n\t\t\t) {\n\t\t\t\tfontFamilyToInstall.fontFace =\n\t\t\t\t\tfontFamilyToInstall.fontFace.filter(\n\t\t\t\t\t\t( fontFaceToInstall ) =>\n\t\t\t\t\t\t\t! checkFontFaceInstalled(\n\t\t\t\t\t\t\t\tfontFaceToInstall,\n\t\t\t\t\t\t\t\tinstalledFontFamily.fontFace\n\t\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Install the fonts (upload the font files to the server and create the post in the database).\n\t\t\tlet sucessfullyInstalledFontFaces = [];\n\t\t\tlet unsucessfullyInstalledFontFaces = [];\n\t\t\tif ( fontFamilyToInstall?.fontFace?.length > 0 ) {\n\t\t\t\tconst response = await batchInstallFontFaces(\n\t\t\t\t\tinstalledFontFamily.id,\n\t\t\t\t\tmakeFontFacesFormData( fontFamilyToInstall )\n\t\t\t\t);\n\t\t\t\tsucessfullyInstalledFontFaces = response?.successes;\n\t\t\t\tunsucessfullyInstalledFontFaces = response?.errors;\n\t\t\t}\n\n\t\t\tconst detailedErrorMessage = unsucessfullyInstalledFontFaces.reduce(\n\t\t\t\t( errorMessageCollection, error ) => {\n\t\t\t\t\treturn `${ errorMessageCollection } ${ error.message }`;\n\t\t\t\t},\n\t\t\t\t''\n\t\t\t);\n\n\t\t\t// If there were no successes and nothing already installed then we don't need to activate anything and can bounce now.\n\t\t\tif (\n\t\t\t\tfontFamilyToInstall?.fontFace?.length > 0 &&\n\t\t\t\tsucessfullyInstalledFontFaces.length === 0 &&\n\t\t\t\talreadyInstalledFontFaces.length === 0\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: Specific error message returned from server. */\n\t\t\t\t\t\t__( 'No font faces were installed. %s' ),\n\t\t\t\t\t\tdetailedErrorMessage\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Use the sucessfully installed font faces\n\t\t\t// As well as any font faces that were already installed (those will be activated)\n\t\t\tif (\n\t\t\t\tsucessfullyInstalledFontFaces?.length > 0 ||\n\t\t\t\talreadyInstalledFontFaces?.length > 0\n\t\t\t) {\n\t\t\t\tfontFamilyToInstall.fontFace = [\n\t\t\t\t\t...sucessfullyInstalledFontFaces,\n\t\t\t\t\t...alreadyInstalledFontFaces,\n\t\t\t\t];\n\t\t\t}\n\n\t\t\t// Activate the font family (add the font family to the global styles).\n\t\t\tactivateCustomFontFamilies( [ fontFamilyToInstall ] );\n\n\t\t\t// Save the global styles to the database.\n\t\t\tsaveSpecifiedEntityEdits( 'root', 'globalStyles', globalStylesId, [\n\t\t\t\t'settings.typography.fontFamilies',\n\t\t\t] );\n\n\t\t\trefreshLibrary();\n\n\t\t\tif ( unsucessfullyInstalledFontFaces.length > 0 ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: Specific error message returned from server. */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some font faces were installed. There were some errors. %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tdetailedErrorMessage\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t} finally {\n\t\t\tsetIsInstalling( false );\n\t\t}\n\t}\n\n\tasync function uninstallFontFamily( fontFamilyToUninstall ) {\n\t\ttry {\n\t\t\t// Uninstall the font family.\n\t\t\t// (Removes the font files from the server and the posts from the database).\n\t\t\tconst uninstalledFontFamily = await fetchUninstallFontFamily(\n\t\t\t\tfontFamilyToUninstall.id\n\t\t\t);\n\n\t\t\t// Deactivate the font family if delete request is successful\n\t\t\t// (Removes the font family from the global styles).\n\t\t\tif ( uninstalledFontFamily.deleted ) {\n\t\t\t\tdeactivateFontFamily( fontFamilyToUninstall );\n\t\t\t\t// Save the global styles to the database.\n\t\t\t\tawait saveSpecifiedEntityEdits(\n\t\t\t\t\t'root',\n\t\t\t\t\t'globalStyles',\n\t\t\t\t\tglobalStylesId,\n\t\t\t\t\t[ 'settings.typography.fontFamilies' ]\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Refresh the library (the library font families from database).\n\t\t\trefreshLibrary();\n\n\t\t\treturn uninstalledFontFamily;\n\t\t} catch ( error ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t`There was an error uninstalling the font family:`,\n\t\t\t\terror\n\t\t\t);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tconst deactivateFontFamily = ( font ) => {\n\t\t// If the user doesn't have custom fonts defined, include as custom fonts all the theme fonts\n\t\t// We want to save as active all the theme fonts at the beginning\n\t\tconst initialCustomFonts = fontFamilies?.[ font.source ] ?? [];\n\t\tconst newCustomFonts = initialCustomFonts.filter(\n\t\t\t( f ) => f.slug !== font.slug\n\t\t);\n\t\tsetFontFamilies( {\n\t\t\t...fontFamilies,\n\t\t\t[ font.source ]: newCustomFonts,\n\t\t} );\n\t};\n\n\tconst activateCustomFontFamilies = ( fontsToAdd ) => {\n\t\t// Merge the existing custom fonts with the new fonts.\n\t\tconst newCustomFonts = mergeFontFamilies(\n\t\t\tfontFamilies?.custom,\n\t\t\tfontsToAdd\n\t\t);\n\t\t// Activate the fonts by set the new custom fonts array.\n\t\tsetFontFamilies( {\n\t\t\t...fontFamilies,\n\t\t\tcustom: newCustomFonts,\n\t\t} );\n\t\t// Add custom fonts to the browser.\n\t\tfontsToAdd.forEach( ( font ) => {\n\t\t\tif ( font.fontFace ) {\n\t\t\t\tfont.fontFace.forEach( ( face ) => {\n\t\t\t\t\t// Load font faces just in the iframe because they already are in the document.\n\t\t\t\t\tloadFontFaceInBrowser(\n\t\t\t\t\t\tface,\n\t\t\t\t\t\tgetDisplaySrcFromFontFace( face.src ),\n\t\t\t\t\t\t'all'\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t};\n\n\tconst toggleActivateFont = ( font, face ) => {\n\t\t// If the user doesn't have custom fonts defined, include as custom fonts all the theme fonts\n\t\t// We want to save as active all the theme fonts at the beginning\n\t\tconst initialFonts = fontFamilies?.[ font.source ] ?? [];\n\t\t// Toggles the received font family or font face\n\t\tconst newFonts = toggleFont( font, face, initialFonts );\n\t\t// Updates the font families activated in global settings:\n\t\tsetFontFamilies( {\n\t\t\t...fontFamilies,\n\t\t\t[ font.source ]: newFonts,\n\t\t} );\n\t};\n\n\tconst loadFontFaceAsset = async ( fontFace ) => {\n\t\t// If the font doesn't have a src, don't load it.\n\t\tif ( ! fontFace.src ) return;\n\t\t// Get the src of the font.\n\t\tconst src = getDisplaySrcFromFontFace( fontFace.src, themeUrl );\n\t\t// If the font is already loaded, don't load it again.\n\t\tif ( ! src || loadedFontUrls.has( src ) ) return;\n\t\t// Load the font in the browser.\n\t\tloadFontFaceInBrowser( fontFace, src, 'document' );\n\t\t// Add the font to the loaded fonts list.\n\t\tloadedFontUrls.add( src );\n\t};\n\n\t// Font Collections\n\tconst [ collections, setFontCollections ] = useState( [] );\n\tconst getFontCollections = async () => {\n\t\tconst response = await fetchFontCollections();\n\t\tsetFontCollections( response );\n\t};\n\tconst getFontCollection = async ( slug ) => {\n\t\ttry {\n\t\t\tconst hasData = !! collections.find(\n\t\t\t\t( collection ) => collection.slug === slug\n\t\t\t)?.font_families;\n\t\t\tif ( hasData ) return;\n\t\t\tconst response = await fetchFontCollection( slug );\n\t\t\tconst updatedCollections = collections.map( ( collection ) =>\n\t\t\t\tcollection.slug === slug\n\t\t\t\t\t? { ...collection, ...response }\n\t\t\t\t\t: collection\n\t\t\t);\n\t\t\tsetFontCollections( updatedCollections );\n\t\t} catch ( e ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( e );\n\t\t\tthrow e;\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tgetFontCollections();\n\t}, [] );\n\n\treturn (\n\t\t<FontLibraryContext.Provider\n\t\t\tvalue={ {\n\t\t\t\tlibraryFontSelected,\n\t\t\t\thandleSetLibraryFontSelected,\n\t\t\t\tthemeFonts,\n\t\t\t\tbaseThemeFonts,\n\t\t\t\tcustomFonts,\n\t\t\t\tbaseCustomFonts,\n\t\t\t\tisFontActivated,\n\t\t\t\tgetFontFacesActivated,\n\t\t\t\tloadFontFaceAsset,\n\t\t\t\tinstallFont,\n\t\t\t\tuninstallFontFamily,\n\t\t\t\ttoggleActivateFont,\n\t\t\t\tgetAvailableFontsOutline,\n\t\t\t\tmodalTabOpen,\n\t\t\t\ttoggleModal,\n\t\t\t\trefreshLibrary,\n\t\t\t\tnotice,\n\t\t\t\tsetNotice,\n\t\t\t\tsaveFontFamilies,\n\t\t\t\tfontFamiliesHasChanges,\n\t\t\t\tisResolvingLibrary,\n\t\t\t\thasResolvedLibrary,\n\t\t\t\tisInstalling,\n\t\t\t\tcollections,\n\t\t\t\tgetFontCollection,\n\t\t\t} }\n\t\t>\n\t\t\t{ children }\n\t\t</FontLibraryContext.Provider>\n\t);\n}\n\nexport default FontLibraryProvider;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;AAC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AI;MACH,MAAMmE,OAAO,GAAG,CAAC,CAAEJ,WAAW,CAAChE,IAAI,CAChCqE,UAAU,IAAMA,UAAU,CAACpE,IAAI,KAAKA,IACvC,CAAC,EAAEqE,aAAa;MAChB,IAAKF,OAAO,EAAG;MACf,MAAMhC,QAAQ,GAAG,MAAMjH,mBAAmB,CAAE8E,IAAK,CAAC;MAClD,MAAMsE,kBAAkB,GAAGP,WAAW,CAAClG,GAAG,CAAIuG,UAAU,IACvDA,UAAU,CAACpE,IAAI,KAAKA,IAAI,GACrB;QAAE,GAAGoE,UAAU;QAAE,GAAGjC;MAAS,CAAC,GAC9BiC,UACJ,CAAC;MACDJ,kBAAkB,CAAEM,kBAAmB,CAAC;IACzC,CAAC,CAAC,OAAQC,CAAC,EAAG;MACb;MACAtB,OAAO,CAACT,KAAK,CAAE+B,CAAE,CAAC;MAClB,MAAMA,CAAC;IACR;EACD,CAAC;EAEDpK,SAAS,CAAE,MAAM;IAChB8J,kBAAkB,CAAC,CAAC;EACrB,CAAC,EAAE,EAAG,CAAC;EAEP,OACCO,aAAA,CAAC1I,kBAAkB,CAAC2I,QAAQ;IAC3BC,KAAK,EAAG;MACP9F,mBAAmB;MACnBe,4BAA4B;MAC5BJ,UAAU;MACVT,cAAc;MACdU,WAAW;MACXE,eAAe;MACf4B,eAAe;MACfI,qBAAqB;MACrBkC,iBAAiB;MACjBjC,WAAW;MACXiB,mBAAmB;MACnBY,kBAAkB;MAClB5C,wBAAwB;MACxBlC,YAAY;MACZuB,WAAW;MACX/C,cAAc;MACdF,MAAM;MACNC,SAAS;MACTwB,gBAAgB;MAChBlC,sBAAsB;MACtBiB,kBAAkB;MAClBE,kBAAkB;MAClBd,YAAY;MACZmH,WAAW;MACXG;IACD;EAAG,GAEDlI,QAC0B,CAAC;AAEhC;AAEA,eAAeD,mBAAmB"}
|
|
1
|
+
{"version":3,"names":["createContext","useState","useEffect","privateApis","blockEditorPrivateApis","useSelect","useDispatch","useEntityRecord","useEntityRecords","store","coreStore","__","fetchGetFontFamilyBySlug","fetchInstallFontFamily","fetchUninstallFontFamily","fetchFontCollections","fetchFontCollection","unlock","useGlobalSetting","setUIValuesNeeded","mergeFontFamilies","loadFontFaceInBrowser","unloadFontFaceInBrowser","getDisplaySrcFromFontFace","makeFontFacesFormData","makeFontFamilyFormData","batchInstallFontFaces","checkFontFaceInstalled","toggleFont","FontLibraryContext","FontLibraryProvider","children","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","globalStylesId","select","__experimentalGetCurrentGlobalStylesId","globalStyles","fontFamiliesHasChanges","edits","settings","typography","fontFamilies","isInstalling","setIsInstalling","refreshKey","setRefreshKey","notice","setNotice","refreshLibrary","Date","now","records","libraryPosts","isResolving","isResolvingLibrary","hasResolved","hasResolvedLibrary","_embed","libraryFonts","map","fontFamilyPost","id","font_family_settings","fontFace","_embedded","font_faces","face","font_face_settings","setFontFamilies","baseFontFamilies","undefined","saveFontFamilies","modalTabOpen","setModalTabOpen","libraryFontSelected","setLibraryFontSelected","baseThemeFonts","theme","f","source","sort","a","b","name","localeCompare","themeFonts","customFonts","custom","baseCustomFonts","handleSetLibraryFontSelected","font","fonts","fontSelected","find","slug","toggleModal","tabName","loadedFontUrls","Set","getAvailableFontsOutline","availableFontFamilies","outline","reduce","acc","availableFontFaces","length","fontStyle","fontWeight","getActivatedFontsOutline","isFontActivated","style","weight","includes","getFontFacesActivated","installFonts","fontFamiliesToInstall","fontFamiliesToActivate","installationErrors","fontFamilyToInstall","isANewFontFamily","installedFontFamily","alreadyInstalledFontFaces","filter","fontFaceToInstall","sucessfullyInstalledFontFaces","unsucessfullyInstalledFontFaces","response","successes","errors","push","concat","unique","item","message","activateCustomFontFamilies","installError","Error","uninstallFontFamily","fontFamilyToUninstall","uninstalledFontFamily","deleted","deactivateFontFamily","error","console","_fontFamilies$font$so","initialCustomFonts","newCustomFonts","forEach","fontsToAdd","src","toggleActivateFont","_fontFamilies$font$so2","initialFonts","newFonts","isFaceActivated","loadFontFaceAsset","has","add","collections","setFontCollections","getFontCollections","getFontCollection","hasData","collection","font_families","updatedCollections","e","createElement","Provider","value"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useState, useEffect } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseEntityRecord,\n\tuseEntityRecords,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tfetchGetFontFamilyBySlug,\n\tfetchInstallFontFamily,\n\tfetchUninstallFontFamily,\n\tfetchFontCollections,\n\tfetchFontCollection,\n} from './resolvers';\nimport { unlock } from '../../../lock-unlock';\nconst { useGlobalSetting } = unlock( blockEditorPrivateApis );\nimport {\n\tsetUIValuesNeeded,\n\tmergeFontFamilies,\n\tloadFontFaceInBrowser,\n\tunloadFontFaceInBrowser,\n\tgetDisplaySrcFromFontFace,\n\tmakeFontFacesFormData,\n\tmakeFontFamilyFormData,\n\tbatchInstallFontFaces,\n\tcheckFontFaceInstalled,\n} from './utils';\nimport { toggleFont } from './utils/toggleFont';\n\nexport const FontLibraryContext = createContext( {} );\n\nfunction FontLibraryProvider( { children } ) {\n\tconst { __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits } =\n\t\tuseDispatch( coreStore );\n\tconst { globalStylesId } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetCurrentGlobalStylesId } = select( coreStore );\n\t\treturn { globalStylesId: __experimentalGetCurrentGlobalStylesId() };\n\t} );\n\n\tconst globalStyles = useEntityRecord(\n\t\t'root',\n\t\t'globalStyles',\n\t\tglobalStylesId\n\t);\n\tconst fontFamiliesHasChanges =\n\t\t!! globalStyles?.edits?.settings?.typography?.fontFamilies;\n\n\tconst [ isInstalling, setIsInstalling ] = useState( false );\n\tconst [ refreshKey, setRefreshKey ] = useState( 0 );\n\tconst [ notice, setNotice ] = useState( null );\n\n\tconst refreshLibrary = () => {\n\t\tsetRefreshKey( Date.now() );\n\t};\n\n\tconst {\n\t\trecords: libraryPosts = [],\n\t\tisResolving: isResolvingLibrary,\n\t\thasResolved: hasResolvedLibrary,\n\t} = useEntityRecords( 'postType', 'wp_font_family', {\n\t\trefreshKey,\n\t\t_embed: true,\n\t} );\n\n\tconst libraryFonts =\n\t\t( libraryPosts || [] ).map( ( fontFamilyPost ) => {\n\t\t\treturn {\n\t\t\t\tid: fontFamilyPost.id,\n\t\t\t\t...fontFamilyPost.font_family_settings,\n\t\t\t\tfontFace:\n\t\t\t\t\tfontFamilyPost?._embedded?.font_faces.map(\n\t\t\t\t\t\t( face ) => face.font_face_settings\n\t\t\t\t\t) || [],\n\t\t\t};\n\t\t} ) || [];\n\n\t// Global Styles (settings) font families\n\tconst [ fontFamilies, setFontFamilies ] = useGlobalSetting(\n\t\t'typography.fontFamilies'\n\t);\n\t// theme.json file font families\n\tconst [ baseFontFamilies ] = useGlobalSetting(\n\t\t'typography.fontFamilies',\n\t\tundefined,\n\t\t'base'\n\t);\n\n\t// Save font families to the global styles post in the database.\n\tconst saveFontFamilies = () => {\n\t\tsaveSpecifiedEntityEdits( 'root', 'globalStyles', globalStylesId, [\n\t\t\t'settings.typography.fontFamilies',\n\t\t] );\n\t};\n\n\t// Library Fonts\n\tconst [ modalTabOpen, setModalTabOpen ] = useState( false );\n\tconst [ libraryFontSelected, setLibraryFontSelected ] = useState( null );\n\n\tconst baseThemeFonts = baseFontFamilies?.theme\n\t\t? baseFontFamilies.theme\n\t\t\t\t.map( ( f ) => setUIValuesNeeded( f, { source: 'theme' } ) )\n\t\t\t\t.sort( ( a, b ) => a.name.localeCompare( b.name ) )\n\t\t: [];\n\n\tconst themeFonts = fontFamilies?.theme\n\t\t? fontFamilies.theme\n\t\t\t\t.map( ( f ) => setUIValuesNeeded( f, { source: 'theme' } ) )\n\t\t\t\t.sort( ( a, b ) => a.name.localeCompare( b.name ) )\n\t\t: [];\n\n\tconst customFonts = fontFamilies?.custom\n\t\t? fontFamilies.custom\n\t\t\t\t.map( ( f ) => setUIValuesNeeded( f, { source: 'custom' } ) )\n\t\t\t\t.sort( ( a, b ) => a.name.localeCompare( b.name ) )\n\t\t: [];\n\n\tconst baseCustomFonts = libraryFonts\n\t\t? libraryFonts\n\t\t\t\t.map( ( f ) => setUIValuesNeeded( f, { source: 'custom' } ) )\n\t\t\t\t.sort( ( a, b ) => a.name.localeCompare( b.name ) )\n\t\t: [];\n\n\tuseEffect( () => {\n\t\tif ( ! modalTabOpen ) {\n\t\t\tsetLibraryFontSelected( null );\n\t\t}\n\t}, [ modalTabOpen ] );\n\n\tconst handleSetLibraryFontSelected = ( font ) => {\n\t\tsetNotice( null );\n\n\t\t// If font is null, reset the selected font\n\t\tif ( ! font ) {\n\t\t\tsetLibraryFontSelected( null );\n\t\t\treturn;\n\t\t}\n\n\t\tconst fonts =\n\t\t\tfont.source === 'theme' ? baseThemeFonts : baseCustomFonts;\n\n\t\t// Tries to find the font in the installed fonts\n\t\tconst fontSelected = fonts.find( ( f ) => f.slug === font.slug );\n\t\t// If the font is not found (it is only defined in custom styles), use the font from custom styles\n\t\tsetLibraryFontSelected( {\n\t\t\t...( fontSelected || font ),\n\t\t\tsource: font.source,\n\t\t} );\n\t};\n\n\tconst toggleModal = ( tabName ) => {\n\t\tsetModalTabOpen( tabName || null );\n\t};\n\n\t// Demo\n\tconst [ loadedFontUrls ] = useState( new Set() );\n\n\tconst getAvailableFontsOutline = ( availableFontFamilies ) => {\n\t\tconst outline = availableFontFamilies.reduce( ( acc, font ) => {\n\t\t\tconst availableFontFaces =\n\t\t\t\tfont?.fontFace && font.fontFace?.length > 0\n\t\t\t\t\t? font?.fontFace.map(\n\t\t\t\t\t\t\t( face ) => `${ face.fontStyle + face.fontWeight }`\n\t\t\t\t\t )\n\t\t\t\t\t: [ 'normal400' ]; // If the font doesn't have fontFace, we assume it is a system font and we add the defaults: normal 400\n\n\t\t\tacc[ font.slug ] = availableFontFaces;\n\t\t\treturn acc;\n\t\t}, {} );\n\t\treturn outline;\n\t};\n\n\tconst getActivatedFontsOutline = ( source ) => {\n\t\tswitch ( source ) {\n\t\t\tcase 'theme':\n\t\t\t\treturn getAvailableFontsOutline( themeFonts );\n\t\t\tcase 'custom':\n\t\t\tdefault:\n\t\t\t\treturn getAvailableFontsOutline( customFonts );\n\t\t}\n\t};\n\n\tconst isFontActivated = ( slug, style, weight, source ) => {\n\t\tif ( ! style && ! weight ) {\n\t\t\treturn !! getActivatedFontsOutline( source )[ slug ];\n\t\t}\n\t\treturn !! getActivatedFontsOutline( source )[ slug ]?.includes(\n\t\t\tstyle + weight\n\t\t);\n\t};\n\n\tconst getFontFacesActivated = ( slug, source ) => {\n\t\treturn getActivatedFontsOutline( source )[ slug ] || [];\n\t};\n\n\tasync function installFonts( fontFamiliesToInstall ) {\n\t\tsetIsInstalling( true );\n\t\ttry {\n\t\t\tconst fontFamiliesToActivate = [];\n\t\t\tlet installationErrors = [];\n\n\t\t\tfor ( const fontFamilyToInstall of fontFamiliesToInstall ) {\n\t\t\t\tlet isANewFontFamily = false;\n\n\t\t\t\t// Get the font family if it already exists.\n\t\t\t\tlet installedFontFamily = await fetchGetFontFamilyBySlug(\n\t\t\t\t\tfontFamilyToInstall.slug\n\t\t\t\t);\n\n\t\t\t\t// Otherwise create it.\n\t\t\t\tif ( ! installedFontFamily ) {\n\t\t\t\t\tisANewFontFamily = true;\n\t\t\t\t\t// Prepare font family form data to install.\n\t\t\t\t\tinstalledFontFamily = await fetchInstallFontFamily(\n\t\t\t\t\t\tmakeFontFamilyFormData( fontFamilyToInstall )\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Collect font faces that have already been installed (to be activated later)\n\t\t\t\tconst alreadyInstalledFontFaces =\n\t\t\t\t\tinstalledFontFamily.fontFace && fontFamilyToInstall.fontFace\n\t\t\t\t\t\t? installedFontFamily.fontFace.filter(\n\t\t\t\t\t\t\t\t( fontFaceToInstall ) =>\n\t\t\t\t\t\t\t\t\tcheckFontFaceInstalled(\n\t\t\t\t\t\t\t\t\t\tfontFaceToInstall,\n\t\t\t\t\t\t\t\t\t\tfontFamilyToInstall.fontFace\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: [];\n\n\t\t\t\t// Filter out Font Faces that have already been installed (so that they are not re-installed)\n\t\t\t\tif (\n\t\t\t\t\tinstalledFontFamily.fontFace &&\n\t\t\t\t\tfontFamilyToInstall.fontFace\n\t\t\t\t) {\n\t\t\t\t\tfontFamilyToInstall.fontFace =\n\t\t\t\t\t\tfontFamilyToInstall.fontFace.filter(\n\t\t\t\t\t\t\t( fontFaceToInstall ) =>\n\t\t\t\t\t\t\t\t! checkFontFaceInstalled(\n\t\t\t\t\t\t\t\t\tfontFaceToInstall,\n\t\t\t\t\t\t\t\t\tinstalledFontFamily.fontFace\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Install the fonts (upload the font files to the server and create the post in the database).\n\t\t\t\tlet sucessfullyInstalledFontFaces = [];\n\t\t\t\tlet unsucessfullyInstalledFontFaces = [];\n\t\t\t\tif ( fontFamilyToInstall?.fontFace?.length > 0 ) {\n\t\t\t\t\tconst response = await batchInstallFontFaces(\n\t\t\t\t\t\tinstalledFontFamily.id,\n\t\t\t\t\t\tmakeFontFacesFormData( fontFamilyToInstall )\n\t\t\t\t\t);\n\t\t\t\t\tsucessfullyInstalledFontFaces = response?.successes;\n\t\t\t\t\tunsucessfullyInstalledFontFaces = response?.errors;\n\t\t\t\t}\n\n\t\t\t\t// Use the sucessfully installed font faces\n\t\t\t\t// As well as any font faces that were already installed (those will be activated)\n\t\t\t\tif (\n\t\t\t\t\tsucessfullyInstalledFontFaces?.length > 0 ||\n\t\t\t\t\talreadyInstalledFontFaces?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfontFamilyToInstall.fontFace = [\n\t\t\t\t\t\t...sucessfullyInstalledFontFaces,\n\t\t\t\t\t\t...alreadyInstalledFontFaces,\n\t\t\t\t\t];\n\t\t\t\t\tfontFamiliesToActivate.push( fontFamilyToInstall );\n\t\t\t\t}\n\n\t\t\t\t// If it's a system font but was installed successfully, activate it.\n\t\t\t\tif (\n\t\t\t\t\tinstalledFontFamily &&\n\t\t\t\t\t! fontFamilyToInstall?.fontFace?.length\n\t\t\t\t) {\n\t\t\t\t\tfontFamiliesToActivate.push( installedFontFamily );\n\t\t\t\t}\n\n\t\t\t\t// If the font family is new and is not a system font, delete it to avoid having font families without font faces.\n\t\t\t\tif (\n\t\t\t\t\tisANewFontFamily &&\n\t\t\t\t\tfontFamilyToInstall?.fontFace?.length > 0 &&\n\t\t\t\t\tsucessfullyInstalledFontFaces?.length === 0\n\t\t\t\t) {\n\t\t\t\t\tawait fetchUninstallFontFamily( installedFontFamily.id );\n\t\t\t\t}\n\n\t\t\t\tinstallationErrors = installationErrors.concat(\n\t\t\t\t\tunsucessfullyInstalledFontFaces\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tinstallationErrors = installationErrors.reduce(\n\t\t\t\t( unique, item ) =>\n\t\t\t\t\tunique.includes( item.message )\n\t\t\t\t\t\t? unique\n\t\t\t\t\t\t: [ ...unique, item.message ],\n\t\t\t\t[]\n\t\t\t);\n\n\t\t\tif ( fontFamiliesToActivate.length > 0 ) {\n\t\t\t\t// Activate the font family (add the font family to the global styles).\n\t\t\t\tactivateCustomFontFamilies( fontFamiliesToActivate );\n\n\t\t\t\t// Save the global styles to the database.\n\t\t\t\tawait saveSpecifiedEntityEdits(\n\t\t\t\t\t'root',\n\t\t\t\t\t'globalStyles',\n\t\t\t\t\tglobalStylesId,\n\t\t\t\t\t[ 'settings.typography.fontFamilies' ]\n\t\t\t\t);\n\n\t\t\t\trefreshLibrary();\n\t\t\t}\n\n\t\t\tif ( installationErrors.length > 0 ) {\n\t\t\t\tconst installError = new Error(\n\t\t\t\t\t__( 'There was an error installing fonts.' )\n\t\t\t\t);\n\n\t\t\t\tinstallError.installationErrors = installationErrors;\n\n\t\t\t\tthrow installError;\n\t\t\t}\n\t\t} finally {\n\t\t\tsetIsInstalling( false );\n\t\t}\n\t}\n\n\tasync function uninstallFontFamily( fontFamilyToUninstall ) {\n\t\ttry {\n\t\t\t// Uninstall the font family.\n\t\t\t// (Removes the font files from the server and the posts from the database).\n\t\t\tconst uninstalledFontFamily = await fetchUninstallFontFamily(\n\t\t\t\tfontFamilyToUninstall.id\n\t\t\t);\n\n\t\t\t// Deactivate the font family if delete request is successful\n\t\t\t// (Removes the font family from the global styles).\n\t\t\tif ( uninstalledFontFamily.deleted ) {\n\t\t\t\tdeactivateFontFamily( fontFamilyToUninstall );\n\t\t\t\t// Save the global styles to the database.\n\t\t\t\tawait saveSpecifiedEntityEdits(\n\t\t\t\t\t'root',\n\t\t\t\t\t'globalStyles',\n\t\t\t\t\tglobalStylesId,\n\t\t\t\t\t[ 'settings.typography.fontFamilies' ]\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Refresh the library (the library font families from database).\n\t\t\trefreshLibrary();\n\n\t\t\treturn uninstalledFontFamily;\n\t\t} catch ( error ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t`There was an error uninstalling the font family:`,\n\t\t\t\terror\n\t\t\t);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tconst deactivateFontFamily = ( font ) => {\n\t\t// If the user doesn't have custom fonts defined, include as custom fonts all the theme fonts\n\t\t// We want to save as active all the theme fonts at the beginning\n\t\tconst initialCustomFonts = fontFamilies?.[ font.source ] ?? [];\n\t\tconst newCustomFonts = initialCustomFonts.filter(\n\t\t\t( f ) => f.slug !== font.slug\n\t\t);\n\t\tsetFontFamilies( {\n\t\t\t...fontFamilies,\n\t\t\t[ font.source ]: newCustomFonts,\n\t\t} );\n\n\t\tif ( font.fontFace ) {\n\t\t\tfont.fontFace.forEach( ( face ) => {\n\t\t\t\tunloadFontFaceInBrowser( face, 'all' );\n\t\t\t} );\n\t\t}\n\t};\n\n\tconst activateCustomFontFamilies = ( fontsToAdd ) => {\n\t\t// Merge the existing custom fonts with the new fonts.\n\t\t// Activate the fonts by set the new custom fonts array.\n\t\tsetFontFamilies( {\n\t\t\t...fontFamilies,\n\t\t\tcustom: mergeFontFamilies( fontFamilies?.custom, fontsToAdd ),\n\t\t} );\n\t\t// Add custom fonts to the browser.\n\t\tfontsToAdd.forEach( ( font ) => {\n\t\t\tif ( font.fontFace ) {\n\t\t\t\tfont.fontFace.forEach( ( face ) => {\n\t\t\t\t\t// Load font faces just in the iframe because they already are in the document.\n\t\t\t\t\tloadFontFaceInBrowser(\n\t\t\t\t\t\tface,\n\t\t\t\t\t\tgetDisplaySrcFromFontFace( face.src ),\n\t\t\t\t\t\t'all'\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t};\n\n\tconst toggleActivateFont = ( font, face ) => {\n\t\t// If the user doesn't have custom fonts defined, include as custom fonts all the theme fonts\n\t\t// We want to save as active all the theme fonts at the beginning\n\t\tconst initialFonts = fontFamilies?.[ font.source ] ?? [];\n\t\t// Toggles the received font family or font face\n\t\tconst newFonts = toggleFont( font, face, initialFonts );\n\t\t// Updates the font families activated in global settings:\n\t\tsetFontFamilies( {\n\t\t\t...fontFamilies,\n\t\t\t[ font.source ]: newFonts,\n\t\t} );\n\n\t\tconst isFaceActivated = isFontActivated(\n\t\t\tfont.slug,\n\t\t\tface?.fontStyle,\n\t\t\tface?.fontWeight,\n\t\t\tfont.source\n\t\t);\n\n\t\tif ( isFaceActivated ) {\n\t\t\tloadFontFaceInBrowser(\n\t\t\t\tface,\n\t\t\t\tgetDisplaySrcFromFontFace( face?.src ),\n\t\t\t\t'all'\n\t\t\t);\n\t\t} else {\n\t\t\tunloadFontFaceInBrowser( face, 'all' );\n\t\t}\n\t};\n\n\tconst loadFontFaceAsset = async ( fontFace ) => {\n\t\t// If the font doesn't have a src, don't load it.\n\t\tif ( ! fontFace.src ) return;\n\t\t// Get the src of the font.\n\t\tconst src = getDisplaySrcFromFontFace( fontFace.src );\n\t\t// If the font is already loaded, don't load it again.\n\t\tif ( ! src || loadedFontUrls.has( src ) ) return;\n\t\t// Load the font in the browser.\n\t\tloadFontFaceInBrowser( fontFace, src, 'document' );\n\t\t// Add the font to the loaded fonts list.\n\t\tloadedFontUrls.add( src );\n\t};\n\n\t// Font Collections\n\tconst [ collections, setFontCollections ] = useState( [] );\n\tconst getFontCollections = async () => {\n\t\tconst response = await fetchFontCollections();\n\t\tsetFontCollections( response );\n\t};\n\tconst getFontCollection = async ( slug ) => {\n\t\ttry {\n\t\t\tconst hasData = !! collections.find(\n\t\t\t\t( collection ) => collection.slug === slug\n\t\t\t)?.font_families;\n\t\t\tif ( hasData ) return;\n\t\t\tconst response = await fetchFontCollection( slug );\n\t\t\tconst updatedCollections = collections.map( ( collection ) =>\n\t\t\t\tcollection.slug === slug\n\t\t\t\t\t? { ...collection, ...response }\n\t\t\t\t\t: collection\n\t\t\t);\n\t\t\tsetFontCollections( updatedCollections );\n\t\t} catch ( e ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( e );\n\t\t\tthrow e;\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tgetFontCollections();\n\t}, [] );\n\n\treturn (\n\t\t<FontLibraryContext.Provider\n\t\t\tvalue={ {\n\t\t\t\tlibraryFontSelected,\n\t\t\t\thandleSetLibraryFontSelected,\n\t\t\t\tthemeFonts,\n\t\t\t\tbaseThemeFonts,\n\t\t\t\tcustomFonts,\n\t\t\t\tbaseCustomFonts,\n\t\t\t\tisFontActivated,\n\t\t\t\tgetFontFacesActivated,\n\t\t\t\tloadFontFaceAsset,\n\t\t\t\tinstallFonts,\n\t\t\t\tuninstallFontFamily,\n\t\t\t\ttoggleActivateFont,\n\t\t\t\tgetAvailableFontsOutline,\n\t\t\t\tmodalTabOpen,\n\t\t\t\ttoggleModal,\n\t\t\t\trefreshLibrary,\n\t\t\t\tnotice,\n\t\t\t\tsetNotice,\n\t\t\t\tsaveFontFamilies,\n\t\t\t\tfontFamiliesHasChanges,\n\t\t\t\tisResolvingLibrary,\n\t\t\t\thasResolvedLibrary,\n\t\t\t\tisInstalling,\n\t\t\t\tcollections,\n\t\t\t\tgetFontCollection,\n\t\t\t} }\n\t\t>\n\t\t\t{ children }\n\t\t</FontLibraryContext.Provider>\n\t);\n}\n\nexport default FontLibraryProvider;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;AACvE,SAASC,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;AAC/E,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,eAAe,EACfC,gBAAgB,EAChBC,KAAK,IAAIC,SAAS,QACZ,sBAAsB;AAC7B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SACCC,wBAAwB,EACxBC,sBAAsB,EACtBC,wBAAwB,EACxBC,oBAAoB,EACpBC,mBAAmB,QACb,aAAa;AACpB,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,MAAM;EAAEC;AAAiB,CAAC,GAAGD,MAAM,CAAEb,sBAAuB,CAAC;AAC7D,SACCe,iBAAiB,EACjBC,iBAAiB,EACjBC,qBAAqB,EACrBC,uBAAuB,EACvBC,yBAAyB,EACzBC,qBAAqB,EACrBC,sBAAsB,EACtBC,qBAAqB,EACrBC,sBAAsB,QAChB,SAAS;AAChB,SAASC,UAAU,QAAQ,oBAAoB;AAE/C,OAAO,MAAMC,kBAAkB,GAAG7B,aAAa,CAAE,CAAC,CAAE,CAAC;AAErD,SAAS8B,mBAAmBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EAC5C,MAAM;IAAEC,sCAAsC,EAAEC;EAAyB,CAAC,GACzE3B,WAAW,CAAEI,SAAU,CAAC;EACzB,MAAM;IAAEwB;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K,CAAC;MAClD,MAAMuE,kBAAkB,GAAGP,WAAW,CAACnG,GAAG,CAAIwG,UAAU,IACvDA,UAAU,CAACrE,IAAI,KAAKA,IAAI,GACrB;QAAE,GAAGqE,UAAU;QAAE,GAAGrC;MAAS,CAAC,GAC9BqC,UACJ,CAAC;MACDJ,kBAAkB,CAAEM,kBAAmB,CAAC;IACzC,CAAC,CAAC,OAAQC,CAAC,EAAG;MACb;MACAvB,OAAO,CAACD,KAAK,CAAEwB,CAAE,CAAC;MAClB,MAAMA,CAAC;IACR;EACD,CAAC;EAEDrK,SAAS,CAAE,MAAM;IAChB+J,kBAAkB,CAAC,CAAC;EACrB,CAAC,EAAE,EAAG,CAAC;EAEP,OACCO,aAAA,CAAC3I,kBAAkB,CAAC4I,QAAQ;IAC3BC,KAAK,EAAG;MACP/F,mBAAmB;MACnBe,4BAA4B;MAC5BJ,UAAU;MACVT,cAAc;MACdU,WAAW;MACXE,eAAe;MACfqB,eAAe;MACfI,qBAAqB;MACrB0C,iBAAiB;MACjBzC,YAAY;MACZuB,mBAAmB;MACnBa,kBAAkB;MAClBnD,wBAAwB;MACxB3B,YAAY;MACZuB,WAAW;MACX/C,cAAc;MACdF,MAAM;MACNC,SAAS;MACTwB,gBAAgB;MAChBlC,sBAAsB;MACtBiB,kBAAkB;MAClBE,kBAAkB;MAClBd,YAAY;MACZoH,WAAW;MACXG;IACD;EAAG,GAEDnI,QAC0B,CAAC;AAEhC;AAEA,eAAeD,mBAAmB"}
|
|
@@ -3,43 +3,38 @@ import { createElement } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { _n, sprintf } from '@wordpress/i18n';
|
|
6
|
-
import { __experimentalText as Text, Button, Flex, FlexItem, Icon } from '@wordpress/components';
|
|
6
|
+
import { __experimentalUseNavigator as useNavigator, __experimentalText as Text, Button, Flex, FlexItem, Icon } from '@wordpress/components';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
import FontDemo from './font-demo';
|
|
12
|
-
import { getFamilyPreviewStyle } from './utils/preview-styles';
|
|
13
12
|
import { chevronRight } from '@wordpress/icons';
|
|
14
13
|
function FontCard({
|
|
15
14
|
font,
|
|
16
15
|
onClick,
|
|
17
|
-
variantsText
|
|
16
|
+
variantsText,
|
|
17
|
+
navigatorPath
|
|
18
18
|
}) {
|
|
19
|
-
const fakeFontFace = {
|
|
20
|
-
fontStyle: 'normal',
|
|
21
|
-
fontWeight: '400',
|
|
22
|
-
fontFamily: font.fontFamily,
|
|
23
|
-
fake: true
|
|
24
|
-
};
|
|
25
|
-
const displayFontFace = font.fontFace && font.fontFace.length ? font?.fontFace?.find(face => face.fontStyle === 'normal' && face.fontWeight === '400') || font.fontFace[0] : fakeFontFace;
|
|
26
|
-
const demoStyle = getFamilyPreviewStyle(font);
|
|
27
19
|
const variantsCount = font.fontFace?.length || 1;
|
|
28
20
|
const style = {
|
|
29
21
|
cursor: !!onClick ? 'pointer' : 'default'
|
|
30
22
|
};
|
|
23
|
+
const navigator = useNavigator();
|
|
31
24
|
return createElement(Button, {
|
|
32
|
-
onClick:
|
|
25
|
+
onClick: () => {
|
|
26
|
+
onClick();
|
|
27
|
+
if (navigatorPath) {
|
|
28
|
+
navigator.goTo(navigatorPath);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
33
31
|
style: style,
|
|
34
32
|
className: "font-library-modal__font-card"
|
|
35
33
|
}, createElement(Flex, {
|
|
36
34
|
justify: "space-between",
|
|
37
35
|
wrap: false
|
|
38
36
|
}, createElement(FontDemo, {
|
|
39
|
-
|
|
40
|
-
fontFace: displayFontFace,
|
|
41
|
-
text: font.name,
|
|
42
|
-
style: demoStyle
|
|
37
|
+
font: font
|
|
43
38
|
}), createElement(Flex, {
|
|
44
39
|
justify: "flex-end"
|
|
45
40
|
}, createElement(FlexItem, null, createElement(Text, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_n","sprintf","__experimentalText","Text","Button","Flex","FlexItem","Icon","FontDemo","
|
|
1
|
+
{"version":3,"names":["_n","sprintf","__experimentalUseNavigator","useNavigator","__experimentalText","Text","Button","Flex","FlexItem","Icon","FontDemo","chevronRight","FontCard","font","onClick","variantsText","navigatorPath","variantsCount","fontFace","length","style","cursor","navigator","createElement","goTo","className","justify","wrap","icon"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/font-card.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _n, sprintf } from '@wordpress/i18n';\nimport {\n\t__experimentalUseNavigator as useNavigator,\n\t__experimentalText as Text,\n\tButton,\n\tFlex,\n\tFlexItem,\n\tIcon,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport FontDemo from './font-demo';\nimport { chevronRight } from '@wordpress/icons';\n\nfunction FontCard( { font, onClick, variantsText, navigatorPath } ) {\n\tconst variantsCount = font.fontFace?.length || 1;\n\n\tconst style = {\n\t\tcursor: !! onClick ? 'pointer' : 'default',\n\t};\n\n\tconst navigator = useNavigator();\n\n\treturn (\n\t\t<Button\n\t\t\tonClick={ () => {\n\t\t\t\tonClick();\n\t\t\t\tif ( navigatorPath ) {\n\t\t\t\t\tnavigator.goTo( navigatorPath );\n\t\t\t\t}\n\t\t\t} }\n\t\t\tstyle={ style }\n\t\t\tclassName=\"font-library-modal__font-card\"\n\t\t>\n\t\t\t<Flex justify=\"space-between\" wrap={ false }>\n\t\t\t\t<FontDemo font={ font } />\n\t\t\t\t<Flex justify=\"flex-end\">\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Text className=\"font-library-modal__font-card__count\">\n\t\t\t\t\t\t\t{ variantsText ||\n\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %d: Number of font variants. */\n\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t'%d variant',\n\t\t\t\t\t\t\t\t\t\t'%d variants',\n\t\t\t\t\t\t\t\t\t\tvariantsCount\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tvariantsCount\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Icon icon={ chevronRight } />\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</Flex>\n\t\t</Button>\n\t);\n}\n\nexport default FontCard;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SACCC,0BAA0B,IAAIC,YAAY,EAC1CC,kBAAkB,IAAIC,IAAI,EAC1BC,MAAM,EACNC,IAAI,EACJC,QAAQ,EACRC,IAAI,QACE,uBAAuB;;AAE9B;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,aAAa;AAClC,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,SAASC,QAAQA,CAAE;EAAEC,IAAI;EAAEC,OAAO;EAAEC,YAAY;EAAEC;AAAc,CAAC,EAAG;EACnE,MAAMC,aAAa,GAAGJ,IAAI,CAACK,QAAQ,EAAEC,MAAM,IAAI,CAAC;EAEhD,MAAMC,KAAK,GAAG;IACbC,MAAM,EAAE,CAAC,CAAEP,OAAO,GAAG,SAAS,GAAG;EAClC,CAAC;EAED,MAAMQ,SAAS,GAAGnB,YAAY,CAAC,CAAC;EAEhC,OACCoB,aAAA,CAACjB,MAAM;IACNQ,OAAO,EAAGA,CAAA,KAAM;MACfA,OAAO,CAAC,CAAC;MACT,IAAKE,aAAa,EAAG;QACpBM,SAAS,CAACE,IAAI,CAAER,aAAc,CAAC;MAChC;IACD,CAAG;IACHI,KAAK,EAAGA,KAAO;IACfK,SAAS,EAAC;EAA+B,GAEzCF,aAAA,CAAChB,IAAI;IAACmB,OAAO,EAAC,eAAe;IAACC,IAAI,EAAG;EAAO,GAC3CJ,aAAA,CAACb,QAAQ;IAACG,IAAI,EAAGA;EAAM,CAAE,CAAC,EAC1BU,aAAA,CAAChB,IAAI;IAACmB,OAAO,EAAC;EAAU,GACvBH,aAAA,CAACf,QAAQ,QACRe,aAAA,CAAClB,IAAI;IAACoB,SAAS,EAAC;EAAsC,GACnDV,YAAY,IACbd,OAAO,EACN;EACAD,EAAE,CACD,YAAY,EACZ,aAAa,EACbiB,aACD,CAAC,EACDA,aACD,CACI,CACG,CAAC,EACXM,aAAA,CAACf,QAAQ,QACRe,aAAA,CAACd,IAAI;IAACmB,IAAI,EAAGjB;EAAc,CAAE,CACpB,CACL,CACD,CACC,CAAC;AAEX;AAEA,eAAeC,QAAQ"}
|
|
@@ -3,34 +3,36 @@ import { createElement, Fragment } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { useContext, useEffect, useState, useMemo, createInterpolateElement } from '@wordpress/element';
|
|
6
|
-
import { __experimentalSpacer as Spacer,
|
|
6
|
+
import { __experimentalSpacer as Spacer, __experimentalText as Text, __experimentalHStack as HStack, __experimentalVStack as VStack, __experimentalNavigatorProvider as NavigatorProvider, __experimentalNavigatorScreen as NavigatorScreen, __experimentalNavigatorToParentButton as NavigatorToParentButton, __experimentalHeading as Heading, Notice, SelectControl, Spinner, FlexItem, Flex, Button, DropdownMenu, SearchControl } from '@wordpress/components';
|
|
7
7
|
import { debounce } from '@wordpress/compose';
|
|
8
8
|
import { sprintf, __, _x } from '@wordpress/i18n';
|
|
9
|
-
import {
|
|
9
|
+
import { moreVertical, chevronLeft } from '@wordpress/icons';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
import TabPanelLayout from './tab-panel-layout';
|
|
15
14
|
import { FontLibraryContext } from './context';
|
|
16
15
|
import FontCard from './font-card';
|
|
17
16
|
import filterFonts from './utils/filter-fonts';
|
|
18
|
-
import CollectionFontDetails from './collection-font-details';
|
|
19
17
|
import { toggleFont } from './utils/toggleFont';
|
|
20
|
-
import { getFontsOutline } from './utils/fonts-outline';
|
|
18
|
+
import { getFontsOutline, isFontFontFaceInOutline } from './utils/fonts-outline';
|
|
21
19
|
import GoogleFontsConfirmDialog from './google-fonts-confirm-dialog';
|
|
22
20
|
import { downloadFontFaceAssets } from './utils';
|
|
21
|
+
import { sortFontFaces } from './utils/sort-font-faces';
|
|
22
|
+
import CollectionFontVariant from './collection-font-variant';
|
|
23
23
|
const DEFAULT_CATEGORY = {
|
|
24
24
|
slug: 'all',
|
|
25
25
|
name: _x('All', 'font categories')
|
|
26
26
|
};
|
|
27
|
+
const LOCAL_STORAGE_ITEM = 'wp-font-library-google-fonts-permission';
|
|
28
|
+
const MIN_WINDOW_HEIGHT = 500;
|
|
27
29
|
function FontCollection({
|
|
28
30
|
slug
|
|
29
31
|
}) {
|
|
30
32
|
var _selectedCollection$c;
|
|
31
33
|
const requiresPermission = slug === 'google-fonts';
|
|
32
34
|
const getGoogleFontsPermissionFromStorage = () => {
|
|
33
|
-
return window.localStorage.getItem(
|
|
35
|
+
return window.localStorage.getItem(LOCAL_STORAGE_ITEM) === 'true';
|
|
34
36
|
};
|
|
35
37
|
const [selectedFont, setSelectedFont] = useState(null);
|
|
36
38
|
const [fontsToInstall, setFontsToInstall] = useState([]);
|
|
@@ -40,7 +42,8 @@ function FontCollection({
|
|
|
40
42
|
const {
|
|
41
43
|
collections,
|
|
42
44
|
getFontCollection,
|
|
43
|
-
|
|
45
|
+
installFonts,
|
|
46
|
+
isInstalling,
|
|
44
47
|
notice,
|
|
45
48
|
setNotice
|
|
46
49
|
} = useContext(FontLibraryContext);
|
|
@@ -53,6 +56,10 @@ function FontCollection({
|
|
|
53
56
|
window.addEventListener('storage', handleStorage);
|
|
54
57
|
return () => window.removeEventListener('storage', handleStorage);
|
|
55
58
|
}, [slug, requiresPermission]);
|
|
59
|
+
const revokeAccess = () => {
|
|
60
|
+
window.localStorage.setItem(LOCAL_STORAGE_ITEM, 'false');
|
|
61
|
+
window.dispatchEvent(new Event('storage'));
|
|
62
|
+
};
|
|
56
63
|
useEffect(() => {
|
|
57
64
|
const fetchFontCollection = async () => {
|
|
58
65
|
try {
|
|
@@ -87,7 +94,8 @@ function FontCollection({
|
|
|
87
94
|
|
|
88
95
|
// NOTE: The height of the font library modal unavailable to use for rendering font family items is roughly 417px
|
|
89
96
|
// The height of each font family item is 61px.
|
|
90
|
-
const
|
|
97
|
+
const windowHeight = Math.max(window.innerHeight, MIN_WINDOW_HEIGHT);
|
|
98
|
+
const pageSize = Math.floor((windowHeight - 417) / 61);
|
|
91
99
|
const totalPages = Math.ceil(fonts.length / pageSize);
|
|
92
100
|
const itemsStart = (page - 1) * pageSize;
|
|
93
101
|
const itemsLimit = page * pageSize;
|
|
@@ -111,16 +119,6 @@ function FontCollection({
|
|
|
111
119
|
setFilters({});
|
|
112
120
|
setPage(1);
|
|
113
121
|
};
|
|
114
|
-
const resetSearch = () => {
|
|
115
|
-
setFilters({
|
|
116
|
-
...filters,
|
|
117
|
-
search: ''
|
|
118
|
-
});
|
|
119
|
-
setPage(1);
|
|
120
|
-
};
|
|
121
|
-
const handleUnselectFont = () => {
|
|
122
|
-
setSelectedFont(null);
|
|
123
|
-
};
|
|
124
122
|
const handleToggleVariant = (font, face) => {
|
|
125
123
|
const newFontsToInstall = toggleFont(font, face, fontsToInstall);
|
|
126
124
|
setFontsToInstall(newFontsToInstall);
|
|
@@ -150,7 +148,7 @@ function FontCollection({
|
|
|
150
148
|
return;
|
|
151
149
|
}
|
|
152
150
|
try {
|
|
153
|
-
await
|
|
151
|
+
await installFonts([fontFamily]);
|
|
154
152
|
setNotice({
|
|
155
153
|
type: 'success',
|
|
156
154
|
message: __('Fonts were installed successfully.')
|
|
@@ -163,39 +161,60 @@ function FontCollection({
|
|
|
163
161
|
}
|
|
164
162
|
resetFontsToInstall();
|
|
165
163
|
};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
164
|
+
const getSortedFontFaces = fontFamily => {
|
|
165
|
+
if (!fontFamily) {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
if (!fontFamily.fontFace || !fontFamily.fontFace.length) {
|
|
169
|
+
return [{
|
|
170
|
+
fontFamily: fontFamily.fontFamily,
|
|
171
|
+
fontStyle: 'normal',
|
|
172
|
+
fontWeight: '400'
|
|
173
|
+
}];
|
|
174
|
+
}
|
|
175
|
+
return sortFontFaces(fontFamily.fontFace);
|
|
176
|
+
};
|
|
177
|
+
if (renderConfirmDialog) {
|
|
178
|
+
return createElement(GoogleFontsConfirmDialog, null);
|
|
178
179
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
180
|
+
const ActionsComponent = () => {
|
|
181
|
+
if (slug !== 'google-fonts' || renderConfirmDialog || selectedFont) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
return createElement(DropdownMenu, {
|
|
185
|
+
icon: moreVertical,
|
|
186
|
+
label: __('Actions'),
|
|
187
|
+
popoverProps: {
|
|
188
|
+
position: 'bottom left'
|
|
189
|
+
},
|
|
190
|
+
controls: [{
|
|
191
|
+
title: __('Revoke access to Google Fonts'),
|
|
192
|
+
onClick: revokeAccess
|
|
193
|
+
}]
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
return createElement("div", {
|
|
197
|
+
className: "font-library-modal__tabpanel-layout"
|
|
198
|
+
}, createElement(NavigatorProvider, {
|
|
199
|
+
initialPath: "/",
|
|
200
|
+
className: "font-library-modal__tabpanel-layout"
|
|
201
|
+
}, createElement(NavigatorScreen, {
|
|
202
|
+
path: "/"
|
|
203
|
+
}, createElement(HStack, {
|
|
204
|
+
justify: "space-between"
|
|
205
|
+
}, createElement(VStack, null, createElement(Heading, {
|
|
206
|
+
level: 2,
|
|
207
|
+
size: 13
|
|
208
|
+
}, selectedCollection.name), createElement(Text, null, selectedCollection.description)), createElement(ActionsComponent, null)), createElement(Spacer, {
|
|
209
|
+
margin: 4
|
|
210
|
+
}), createElement(Flex, null, createElement(FlexItem, null, createElement(SearchControl, {
|
|
211
|
+
className: "font-library-modal__search",
|
|
188
212
|
value: filters.search,
|
|
189
213
|
placeholder: __('Font name…'),
|
|
190
214
|
label: __('Search'),
|
|
191
215
|
onChange: debouncedUpdateSearchInput,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}),
|
|
195
|
-
suffix: filters?.search ? createElement(Icon, {
|
|
196
|
-
icon: closeSmall,
|
|
197
|
-
onClick: resetSearch
|
|
198
|
-
}) : null
|
|
216
|
+
__nextHasNoMarginBottom: true,
|
|
217
|
+
hideLabelFromVision: false
|
|
199
218
|
})), createElement(FlexItem, null, createElement(SelectControl, {
|
|
200
219
|
label: __('Category'),
|
|
201
220
|
value: filters.category,
|
|
@@ -205,27 +224,68 @@ function FontCollection({
|
|
|
205
224
|
key: category.slug
|
|
206
225
|
}, category.name))))), createElement(Spacer, {
|
|
207
226
|
margin: 4
|
|
208
|
-
}), !
|
|
209
|
-
font: selectedFont,
|
|
210
|
-
handleToggleVariant: handleToggleVariant,
|
|
211
|
-
fontToInstallOutline: fontToInstallOutline
|
|
212
|
-
}), !renderConfirmDialog && !selectedFont && createElement("div", {
|
|
227
|
+
}), !selectedCollection?.font_families && !notice && createElement(Spinner, null), !!selectedCollection?.font_families?.length && !fonts.length && createElement(Text, null, __('No fonts found. Try with a different search term')), createElement("div", {
|
|
213
228
|
className: "font-library-modal__fonts-grid__main"
|
|
214
229
|
}, items.map(font => createElement(FontCard, {
|
|
215
230
|
key: font.font_family_settings.slug,
|
|
216
231
|
font: font.font_family_settings,
|
|
232
|
+
navigatorPath: '/fontFamily',
|
|
217
233
|
onClick: () => {
|
|
218
234
|
setSelectedFont(font.font_family_settings);
|
|
219
235
|
}
|
|
220
|
-
}))))
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
236
|
+
})))), createElement(NavigatorScreen, {
|
|
237
|
+
path: "/fontFamily"
|
|
238
|
+
}, createElement(Flex, {
|
|
239
|
+
justify: "flex-start"
|
|
240
|
+
}, createElement(NavigatorToParentButton, {
|
|
241
|
+
icon: chevronLeft,
|
|
242
|
+
size: "small",
|
|
243
|
+
onClick: () => {
|
|
244
|
+
setSelectedFont(null);
|
|
245
|
+
setNotice(null);
|
|
246
|
+
},
|
|
247
|
+
label: __('Back')
|
|
248
|
+
}), createElement(Heading, {
|
|
249
|
+
level: 2,
|
|
250
|
+
size: 13,
|
|
251
|
+
className: "edit-site-global-styles-header"
|
|
252
|
+
}, selectedFont?.name)), notice && createElement(Fragment, null, createElement(Spacer, {
|
|
253
|
+
margin: 1
|
|
254
|
+
}), createElement(Notice, {
|
|
255
|
+
status: notice.type,
|
|
256
|
+
onRemove: () => setNotice(null)
|
|
257
|
+
}, notice.message), createElement(Spacer, {
|
|
258
|
+
margin: 1
|
|
259
|
+
})), createElement(Spacer, {
|
|
260
|
+
margin: 4
|
|
261
|
+
}), createElement(Text, null, " ", __('Select font variants to install.'), " "), createElement(Spacer, {
|
|
262
|
+
margin: 4
|
|
263
|
+
}), createElement(VStack, {
|
|
264
|
+
spacing: 0
|
|
265
|
+
}, createElement(Spacer, {
|
|
266
|
+
margin: 8
|
|
267
|
+
}), getSortedFontFaces(selectedFont).map((face, i) => createElement(CollectionFontVariant, {
|
|
268
|
+
font: selectedFont,
|
|
269
|
+
face: face,
|
|
270
|
+
key: `face${i}`,
|
|
271
|
+
handleToggleVariant: handleToggleVariant,
|
|
272
|
+
selected: isFontFontFaceInOutline(selectedFont.slug, selectedFont.fontFace ? face : null,
|
|
273
|
+
// If the font has no fontFace, we want to check if the font is in the outline
|
|
274
|
+
fontToInstallOutline)
|
|
275
|
+
}))), createElement(Spacer, {
|
|
276
|
+
margin: 16
|
|
277
|
+
}))), selectedFont && createElement(Flex, {
|
|
278
|
+
justify: "flex-end",
|
|
279
|
+
className: "font-library-modal__tabpanel-layout__footer"
|
|
280
|
+
}, createElement(Button, {
|
|
281
|
+
variant: "primary",
|
|
282
|
+
onClick: handleInstall,
|
|
283
|
+
isBusy: isInstalling,
|
|
284
|
+
disabled: fontsToInstall.length === 0 || isInstalling,
|
|
285
|
+
__experimentalIsFocusable: true
|
|
286
|
+
}, __('Install'))), !selectedFont && createElement(Flex, {
|
|
287
|
+
justify: "center",
|
|
288
|
+
className: "font-library-modal__tabpanel-layout__footer"
|
|
229
289
|
}, createElement(Button, {
|
|
230
290
|
label: __('First page'),
|
|
231
291
|
size: "compact",
|
|
@@ -244,8 +304,8 @@ function PaginationFooter({
|
|
|
244
304
|
spacing: 2
|
|
245
305
|
}, createInterpolateElement(sprintf(
|
|
246
306
|
// translators: %s: Total number of pages.
|
|
247
|
-
_x('Page <
|
|
248
|
-
|
|
307
|
+
_x('Page <CurrentPageControl /> of %s', 'paging'), totalPages), {
|
|
308
|
+
CurrentPageControl: createElement(SelectControl, {
|
|
249
309
|
"aria-label": __('Current page'),
|
|
250
310
|
value: page,
|
|
251
311
|
options: [...Array(totalPages)].map((e, i) => {
|
|
@@ -270,24 +330,7 @@ function PaginationFooter({
|
|
|
270
330
|
onClick: () => setPage(totalPages),
|
|
271
331
|
disabled: page === totalPages,
|
|
272
332
|
__experimentalIsFocusable: true
|
|
273
|
-
}, createElement("span", null, "\xBB")));
|
|
274
|
-
}
|
|
275
|
-
function InstallFooter({
|
|
276
|
-
handleInstall,
|
|
277
|
-
isDisabled
|
|
278
|
-
}) {
|
|
279
|
-
const {
|
|
280
|
-
isInstalling
|
|
281
|
-
} = useContext(FontLibraryContext);
|
|
282
|
-
return createElement(Flex, {
|
|
283
|
-
justify: "flex-end"
|
|
284
|
-
}, createElement(Button, {
|
|
285
|
-
variant: "primary",
|
|
286
|
-
onClick: handleInstall,
|
|
287
|
-
isBusy: isInstalling,
|
|
288
|
-
disabled: isDisabled || isInstalling,
|
|
289
|
-
__experimentalIsFocusable: true
|
|
290
|
-
}, __('Install')));
|
|
333
|
+
}, createElement("span", null, "\xBB"))));
|
|
291
334
|
}
|
|
292
335
|
export default FontCollection;
|
|
293
336
|
//# sourceMappingURL=font-collection.js.map
|