@wordpress/edit-site 5.19.0 → 5.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/add-new-pattern/index.js +3 -3
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/block-editor/block-editor-provider/default-block-editor-provider.js +73 -0
- package/build/components/block-editor/block-editor-provider/default-block-editor-provider.js.map +1 -0
- package/build/components/block-editor/block-editor-provider/index.js +31 -0
- package/build/components/block-editor/block-editor-provider/index.js.map +1 -0
- package/build/components/block-editor/{providers → block-editor-provider}/navigation-block-editor-provider.js +2 -1
- package/build/components/block-editor/block-editor-provider/navigation-block-editor-provider.js.map +1 -0
- package/build/components/block-editor/block-editor-provider/use-page-content-blocks.js +76 -0
- package/build/components/block-editor/block-editor-provider/use-page-content-blocks.js.map +1 -0
- package/build/components/block-editor/index.js +2 -9
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/site-editor-canvas.js +1 -1
- package/build/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +8 -12
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/editor/index.js +4 -1
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/font-family-item.js +2 -2
- package/build/components/global-styles/font-family-item.js.map +1 -1
- package/build/components/global-styles/font-library-modal/collection-font-details.js +49 -0
- package/build/components/global-styles/font-library-modal/collection-font-details.js.map +1 -0
- package/build/components/global-styles/font-library-modal/collection-font-variant.js +55 -0
- package/build/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -0
- package/build/components/global-styles/font-library-modal/context.js +26 -2
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-card.js +7 -4
- 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 +172 -0
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -0
- package/build/components/global-styles/font-library-modal/font-demo.js +30 -13
- 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 +41 -0
- package/build/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +1 -0
- package/build/components/global-styles/font-library-modal/index.js +25 -7
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +2 -2
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/library-font-card.js +0 -5
- package/build/components/global-styles/font-library-modal/library-font-card.js.map +1 -1
- package/build/components/global-styles/font-library-modal/library-font-details.js +2 -1
- package/build/components/global-styles/font-library-modal/library-font-details.js.map +1 -1
- package/build/components/global-styles/font-library-modal/resolvers.js +16 -0
- package/build/components/global-styles/font-library-modal/resolvers.js.map +1 -1
- package/build/components/global-styles/font-library-modal/tab-layout.js +2 -2
- package/build/components/global-styles/font-library-modal/tab-layout.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/constants.js +1 -7
- package/build/components/global-styles/font-library-modal/utils/constants.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/filter-fonts.js +21 -0
- package/build/components/global-styles/font-library-modal/utils/filter-fonts.js.map +1 -0
- package/build/components/global-styles/font-library-modal/utils/fonts-outline.js +20 -0
- package/build/components/global-styles/font-library-modal/utils/fonts-outline.js.map +1 -0
- package/build/components/global-styles/font-library-modal/utils/index.js +2 -52
- 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 +76 -0
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -0
- package/build/components/global-styles/font-library-modal/utils/sort-font-faces.js +36 -0
- package/build/components/global-styles/font-library-modal/utils/sort-font-faces.js.map +1 -0
- package/build/components/global-styles/screen-typography.js +1 -1
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +9 -8
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +4 -1
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/layout/index.js +5 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/added-by.js +13 -8
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/list/index.js +2 -1
- package/build/components/list/index.js.map +1 -1
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +2 -3
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/page-patterns/duplicate-menu-item.js +5 -5
- package/build/components/page-patterns/duplicate-menu-item.js.map +1 -1
- package/build/components/page-patterns/grid-item.js +5 -5
- package/build/components/page-patterns/grid-item.js.map +1 -1
- package/build/components/page-patterns/index.js +1 -1
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/search-items.js +1 -1
- package/build/components/page-patterns/search-items.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +28 -34
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-template-parts/add-new-template-part.js +3 -2
- package/build/components/page-template-parts/add-new-template-part.js.map +1 -1
- package/build/components/page-template-parts/index.js +2 -1
- package/build/components/page-template-parts/index.js.map +1 -1
- package/build/components/page-templates/index.js +3 -2
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/save-hub/index.js +2 -1
- package/build/components/save-hub/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +24 -17
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/edit-template.js +21 -3
- package/build/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/hooks.js +2 -1
- package/build/components/sidebar-edit-mode/page-panels/hooks.js.map +1 -1
- package/build/components/sidebar-edit-mode/settings-header/index.js +2 -6
- package/build/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/pattern-categories.js +9 -2
- package/build/components/sidebar-edit-mode/template-panel/pattern-categories.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js +2 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +2 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +3 -2
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/page-details.js +2 -1
- package/build/components/sidebar-navigation-screen-page/page-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +5 -4
- package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/index.js +2 -1
- package/build/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js +3 -2
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +2 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +2 -1
- package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +8 -7
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +3 -3
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +7 -2
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +7 -2
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/home-template-details.js +2 -1
- package/build/components/sidebar-navigation-screen-template/home-template-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +4 -3
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +3 -2
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/start-template-options/index.js +20 -2
- 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 +5 -4
- 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 +4 -3
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-actions/index.js +2 -1
- package/build/components/template-actions/index.js.map +1 -1
- package/build/components/template-actions/rename-menu-item.js +8 -3
- package/build/components/template-actions/rename-menu-item.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +4 -3
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/hooks/navigation-menu-edit.js +2 -1
- package/build/hooks/navigation-menu-edit.js.map +1 -1
- package/build/hooks/template-part-edit.js +2 -1
- package/build/hooks/template-part-edit.js.map +1 -1
- package/build/store/actions.js +10 -9
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +1 -9
- package/build/store/constants.js.map +1 -1
- package/build/store/private-actions.js +21 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +23 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +19 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +3 -2
- package/build/store/selectors.js.map +1 -1
- package/build/utils/constants.js +22 -3
- package/build/utils/constants.js.map +1 -1
- package/build/utils/is-template-removable.js +1 -1
- package/build/utils/is-template-removable.js.map +1 -1
- package/build/utils/is-template-revertable.js +1 -1
- package/build/utils/is-template-revertable.js.map +1 -1
- package/build/utils/template-part-create.js +6 -1
- package/build/utils/template-part-create.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +3 -3
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/block-editor/block-editor-provider/default-block-editor-provider.js +65 -0
- package/build-module/components/block-editor/block-editor-provider/default-block-editor-provider.js.map +1 -0
- package/build-module/components/block-editor/block-editor-provider/index.js +23 -0
- package/build-module/components/block-editor/block-editor-provider/index.js.map +1 -0
- package/build-module/components/block-editor/{providers → block-editor-provider}/navigation-block-editor-provider.js +2 -1
- package/build-module/components/block-editor/block-editor-provider/navigation-block-editor-provider.js.map +1 -0
- package/build-module/components/block-editor/block-editor-provider/use-page-content-blocks.js +70 -0
- package/build-module/components/block-editor/block-editor-provider/use-page-content-blocks.js.map +1 -0
- package/build-module/components/block-editor/index.js +1 -8
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/site-editor-canvas.js +2 -2
- package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +8 -12
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +4 -1
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/font-family-item.js +2 -2
- package/build-module/components/global-styles/font-family-item.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/collection-font-details.js +40 -0
- package/build-module/components/global-styles/font-library-modal/collection-font-details.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js +45 -0
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/context.js +27 -3
- 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 +8 -5
- 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 +164 -0
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/font-demo.js +30 -13
- 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 +33 -0
- package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/index.js +26 -7
- 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 +2 -2
- 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-card.js +0 -5
- package/build-module/components/global-styles/font-library-modal/library-font-card.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/library-font-details.js +2 -1
- package/build-module/components/global-styles/font-library-modal/library-font-details.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/resolvers.js +14 -0
- package/build-module/components/global-styles/font-library-modal/resolvers.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/tab-layout.js +2 -2
- package/build-module/components/global-styles/font-library-modal/tab-layout.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/constants.js +1 -6
- package/build-module/components/global-styles/font-library-modal/utils/constants.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js +15 -0
- package/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/utils/fonts-outline.js +13 -0
- package/build-module/components/global-styles/font-library-modal/utils/fonts-outline.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/utils/index.js +2 -51
- 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 +68 -0
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/utils/sort-font-faces.js +30 -0
- package/build-module/components/global-styles/font-library-modal/utils/sort-font-faces.js.map +1 -0
- package/build-module/components/global-styles/screen-typography.js +1 -1
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +9 -8
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +4 -1
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/layout/index.js +5 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/added-by.js +13 -8
- package/build-module/components/list/added-by.js.map +1 -1
- package/build-module/components/list/index.js +2 -1
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +2 -3
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/page-patterns/duplicate-menu-item.js +5 -5
- package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -1
- package/build-module/components/page-patterns/grid-item.js +5 -5
- package/build-module/components/page-patterns/grid-item.js.map +1 -1
- package/build-module/components/page-patterns/index.js +1 -1
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/search-items.js +2 -2
- package/build-module/components/page-patterns/search-items.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +28 -35
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-template-parts/add-new-template-part.js +3 -2
- package/build-module/components/page-template-parts/add-new-template-part.js.map +1 -1
- package/build-module/components/page-template-parts/index.js +2 -1
- package/build-module/components/page-template-parts/index.js.map +1 -1
- package/build-module/components/page-templates/index.js +3 -2
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/save-hub/index.js +2 -1
- package/build-module/components/save-hub/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +26 -19
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js +21 -3
- package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/hooks.js +2 -1
- package/build-module/components/sidebar-edit-mode/page-panels/hooks.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/settings-header/index.js +2 -6
- package/build-module/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/pattern-categories.js +9 -2
- package/build-module/components/sidebar-edit-mode/template-panel/pattern-categories.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js +2 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +3 -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-navigation-menus/index.js +3 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/page-details.js +2 -1
- package/build-module/components/sidebar-navigation-screen-page/page-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +5 -4
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/index.js +2 -1
- package/build-module/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js +3 -2
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +2 -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/use-navigation-menu-content.js +2 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +8 -7
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +4 -4
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +8 -3
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +7 -2
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/home-template-details.js +2 -1
- package/build-module/components/sidebar-navigation-screen-template/home-template-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +4 -3
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +3 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +20 -2
- 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 +5 -4
- 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 +4 -3
- 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 +2 -1
- package/build-module/components/template-actions/index.js.map +1 -1
- package/build-module/components/template-actions/rename-menu-item.js +8 -3
- package/build-module/components/template-actions/rename-menu-item.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +4 -3
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/hooks/navigation-menu-edit.js +2 -1
- package/build-module/hooks/navigation-menu-edit.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +2 -1
- package/build-module/hooks/template-part-edit.js.map +1 -1
- package/build-module/store/actions.js +10 -10
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +0 -4
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/private-actions.js +19 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +22 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +18 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +3 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/constants.js +17 -1
- package/build-module/utils/constants.js.map +1 -1
- package/build-module/utils/is-template-removable.js +2 -2
- package/build-module/utils/is-template-removable.js.map +1 -1
- package/build-module/utils/is-template-revertable.js +2 -2
- package/build-module/utils/is-template-revertable.js.map +1 -1
- package/build-module/utils/template-part-create.js +6 -1
- package/build-module/utils/template-part-create.js.map +1 -1
- package/build-style/style-rtl.css +23 -0
- package/build-style/style.css +23 -0
- package/package.json +40 -40
- package/src/components/add-new-pattern/index.js +3 -3
- package/src/components/block-editor/block-editor-provider/default-block-editor-provider.js +70 -0
- package/src/components/block-editor/block-editor-provider/index.js +29 -0
- package/src/components/block-editor/{providers → block-editor-provider}/navigation-block-editor-provider.js +2 -1
- package/src/components/block-editor/block-editor-provider/test/use-page-content-blocks.js +87 -0
- package/src/components/block-editor/block-editor-provider/use-page-content-blocks.js +77 -0
- package/src/components/block-editor/index.js +1 -14
- package/src/components/block-editor/site-editor-canvas.js +5 -2
- package/src/components/create-template-part-modal/index.js +11 -12
- package/src/components/editor/index.js +6 -2
- package/src/components/global-styles/font-family-item.js +2 -2
- package/src/components/global-styles/font-library-modal/collection-font-details.js +56 -0
- package/src/components/global-styles/font-library-modal/collection-font-variant.js +45 -0
- package/src/components/global-styles/font-library-modal/context.js +33 -2
- package/src/components/global-styles/font-library-modal/font-card.js +9 -4
- package/src/components/global-styles/font-library-modal/font-collection.js +257 -0
- package/src/components/global-styles/font-library-modal/font-demo.js +36 -10
- package/src/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +50 -0
- package/src/components/global-styles/font-library-modal/index.js +30 -5
- package/src/components/global-styles/font-library-modal/installed-fonts.js +1 -1
- package/src/components/global-styles/font-library-modal/library-font-card.js +1 -8
- package/src/components/global-styles/font-library-modal/library-font-details.js +2 -3
- package/src/components/global-styles/font-library-modal/resolvers.js +16 -0
- package/src/components/global-styles/font-library-modal/style.scss +26 -0
- package/src/components/global-styles/font-library-modal/tab-layout.js +2 -2
- package/src/components/global-styles/font-library-modal/utils/constants.js +1 -9
- package/src/components/global-styles/font-library-modal/utils/filter-fonts.js +18 -0
- package/src/components/global-styles/font-library-modal/utils/fonts-outline.js +21 -0
- package/src/components/global-styles/font-library-modal/utils/index.js +9 -69
- package/src/components/global-styles/font-library-modal/utils/preview-styles.js +86 -0
- package/src/components/global-styles/font-library-modal/utils/sort-font-faces.js +33 -0
- package/src/components/global-styles/font-library-modal/utils/test/filter-fonts.spec.js +69 -0
- package/src/components/global-styles/font-library-modal/utils/test/fonts-outline.spec.js +109 -0
- package/src/components/global-styles/font-library-modal/utils/test/{getPreviewStyle.spec.js → preview-styles.spec.js} +49 -9
- package/src/components/global-styles/font-library-modal/utils/test/sort-font-faces.js +74 -0
- package/src/components/global-styles/screen-typography.js +3 -1
- package/src/components/header-edit-mode/document-actions/index.js +17 -8
- package/src/components/header-edit-mode/index.js +2 -1
- package/src/components/layout/index.js +10 -1
- package/src/components/list/added-by.js +29 -11
- package/src/components/list/index.js +7 -1
- package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +2 -8
- package/src/components/page-patterns/duplicate-menu-item.js +5 -5
- package/src/components/page-patterns/grid-item.js +5 -5
- package/src/components/page-patterns/index.js +1 -1
- package/src/components/page-patterns/search-items.js +7 -1
- package/src/components/page-patterns/use-patterns.js +190 -134
- package/src/components/page-template-parts/add-new-template-part.js +5 -2
- package/src/components/page-template-parts/index.js +2 -1
- package/src/components/page-templates/index.js +3 -2
- package/src/components/save-hub/index.js +2 -1
- package/src/components/secondary-sidebar/list-view-sidebar.js +31 -26
- package/src/components/sidebar-edit-mode/page-panels/edit-template.js +48 -20
- package/src/components/sidebar-edit-mode/page-panels/hooks.js +9 -4
- package/src/components/sidebar-edit-mode/page-panels/style.scss +6 -0
- package/src/components/sidebar-edit-mode/settings-header/index.js +4 -7
- package/src/components/sidebar-edit-mode/template-panel/pattern-categories.js +9 -2
- package/src/components/sidebar-navigation-screen-navigation-menu/edit-button.js +2 -1
- package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +3 -1
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +3 -2
- package/src/components/sidebar-navigation-screen-page/page-details.js +2 -1
- package/src/components/sidebar-navigation-screen-pages/index.js +5 -4
- package/src/components/sidebar-navigation-screen-pattern/index.js +2 -1
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js +8 -2
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +7 -1
- package/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +2 -1
- package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +18 -8
- package/src/components/sidebar-navigation-screen-patterns/index.js +8 -4
- package/src/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +16 -3
- package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +12 -2
- package/src/components/sidebar-navigation-screen-template/home-template-details.js +2 -1
- package/src/components/sidebar-navigation-screen-templates/index.js +4 -3
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +6 -2
- package/src/components/start-template-options/index.js +39 -2
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +10 -4
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +8 -3
- package/src/components/template-actions/index.js +2 -1
- package/src/components/template-actions/rename-menu-item.js +8 -3
- package/src/hooks/commands/use-edit-mode-commands.js +4 -3
- package/src/hooks/navigation-menu-edit.js +2 -1
- package/src/hooks/template-part-edit.js +2 -1
- package/src/store/actions.js +18 -10
- package/src/store/constants.js +0 -5
- package/src/store/private-actions.js +19 -0
- package/src/store/private-selectors.js +22 -0
- package/src/store/reducer.js +18 -0
- package/src/store/selectors.js +6 -3
- package/src/store/test/reducer.js +18 -0
- package/src/utils/constants.js +17 -1
- package/src/utils/is-template-removable.js +2 -2
- package/src/utils/is-template-revertable.js +2 -2
- package/src/utils/template-part-create.js +6 -1
- package/build/components/block-editor/get-block-editor-provider.js +0 -35
- package/build/components/block-editor/get-block-editor-provider.js.map +0 -1
- package/build/components/block-editor/providers/default-block-editor-provider.js +0 -49
- package/build/components/block-editor/providers/default-block-editor-provider.js.map +0 -1
- package/build/components/block-editor/providers/navigation-block-editor-provider.js.map +0 -1
- package/build-module/components/block-editor/get-block-editor-provider.js +0 -28
- package/build-module/components/block-editor/get-block-editor-provider.js.map +0 -1
- package/build-module/components/block-editor/providers/default-block-editor-provider.js +0 -41
- package/build-module/components/block-editor/providers/default-block-editor-provider.js.map +0 -1
- package/build-module/components/block-editor/providers/navigation-block-editor-provider.js.map +0 -1
- package/src/components/block-editor/get-block-editor-provider.js +0 -29
- package/src/components/block-editor/providers/default-block-editor-provider.js +0 -44
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __, sprintf } from '@wordpress/i18n';
|
|
5
5
|
import { useContext } from '@wordpress/element';
|
|
6
|
-
import { Icon } from '@wordpress/components';
|
|
7
|
-
import { chevronRight } from '@wordpress/icons';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* Internal dependencies
|
|
@@ -28,12 +26,7 @@ function LibraryFontCard( { font, ...props } ) {
|
|
|
28
26
|
);
|
|
29
27
|
|
|
30
28
|
return (
|
|
31
|
-
<FontCard
|
|
32
|
-
font={ font }
|
|
33
|
-
variantsText={ variantsText }
|
|
34
|
-
actionHandler={ <Icon icon={ chevronRight } /> }
|
|
35
|
-
{ ...props }
|
|
36
|
-
/>
|
|
29
|
+
<FontCard font={ font } variantsText={ variantsText } { ...props } />
|
|
37
30
|
);
|
|
38
31
|
}
|
|
39
32
|
|
|
@@ -10,13 +10,12 @@ import {
|
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
12
|
import LibraryFontVariant from './library-font-variant';
|
|
13
|
+
import { sortFontFaces } from './utils/sort-font-faces';
|
|
13
14
|
|
|
14
15
|
function LibraryFontDetails( { font } ) {
|
|
15
16
|
const fontFaces =
|
|
16
17
|
font.fontFace && font.fontFace.length
|
|
17
|
-
? font.fontFace
|
|
18
|
-
a.fontWeight > b.fontWeight ? 1 : -1
|
|
19
|
-
)
|
|
18
|
+
? sortFontFaces( font.fontFace )
|
|
20
19
|
: [
|
|
21
20
|
{
|
|
22
21
|
fontFamily: font.fontFamily,
|
|
@@ -27,3 +27,19 @@ export async function fetchUninstallFonts( fonts ) {
|
|
|
27
27
|
};
|
|
28
28
|
return apiFetch( config );
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
export async function fetchFontCollections() {
|
|
32
|
+
const config = {
|
|
33
|
+
path: '/wp/v2/fonts/collections',
|
|
34
|
+
method: 'GET',
|
|
35
|
+
};
|
|
36
|
+
return apiFetch( config );
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function fetchFontCollection( id ) {
|
|
40
|
+
const config = {
|
|
41
|
+
path: `/wp/v2/fonts/collections/${ id }`,
|
|
42
|
+
method: 'GET',
|
|
43
|
+
};
|
|
44
|
+
return apiFetch( config );
|
|
45
|
+
}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
.font-library-modal {
|
|
2
|
+
// @todo: If a new prop is added to the Modal component that constrains
|
|
3
|
+
// the content width, we should use that prop instead of this style.
|
|
4
|
+
// see https://github.com/WordPress/gutenberg/issues/54471.
|
|
5
|
+
&.font-library-modal {
|
|
6
|
+
|
|
7
|
+
@include break-medium() {
|
|
8
|
+
width: 65vw;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
2
12
|
.components-modal__header {
|
|
3
13
|
border-bottom: none;
|
|
4
14
|
}
|
|
@@ -111,3 +121,19 @@
|
|
|
111
121
|
background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
|
|
112
122
|
}
|
|
113
123
|
}
|
|
124
|
+
|
|
125
|
+
.font-library__google-fonts-confirm {
|
|
126
|
+
display: flex;
|
|
127
|
+
justify-content: center;
|
|
128
|
+
align-items: center;
|
|
129
|
+
|
|
130
|
+
h3 {
|
|
131
|
+
font-size: 1.4rem;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.components-card {
|
|
135
|
+
width: 50%;
|
|
136
|
+
min-width: 250px;
|
|
137
|
+
max-width: 350px;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -24,7 +24,7 @@ function TabLayout( { title, description, handleBack, children, footer } ) {
|
|
|
24
24
|
variant="tertiary"
|
|
25
25
|
onClick={ handleBack }
|
|
26
26
|
icon={ chevronLeft }
|
|
27
|
-
|
|
27
|
+
size="small"
|
|
28
28
|
/>
|
|
29
29
|
) }
|
|
30
30
|
{ title && (
|
|
@@ -41,7 +41,7 @@ function TabLayout( { title, description, handleBack, children, footer } ) {
|
|
|
41
41
|
</VStack>
|
|
42
42
|
</header>
|
|
43
43
|
<main>{ children }</main>
|
|
44
|
-
<footer>{ footer }</footer>
|
|
44
|
+
{ footer && <footer>{ footer }</footer> }
|
|
45
45
|
</VStack>
|
|
46
46
|
</div>
|
|
47
47
|
);
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export const MODAL_TABS = [
|
|
7
|
-
{
|
|
8
|
-
name: 'installed-fonts',
|
|
9
|
-
title: __( 'Library' ),
|
|
10
|
-
className: 'installed-fonts',
|
|
11
|
-
},
|
|
12
|
-
];
|
|
4
|
+
import { _x } from '@wordpress/i18n';
|
|
13
5
|
|
|
14
6
|
export const ALLOWED_FILE_EXTENSIONS = [ 'otf', 'ttf', 'woff', 'woff2' ];
|
|
15
7
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default function filterFonts( fonts, filters ) {
|
|
2
|
+
const { category, search } = filters;
|
|
3
|
+
let filteredFonts = fonts || [];
|
|
4
|
+
|
|
5
|
+
if ( category && category !== 'all' ) {
|
|
6
|
+
filteredFonts = filteredFonts.filter(
|
|
7
|
+
( font ) => font.category === category
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if ( search ) {
|
|
12
|
+
filteredFonts = filteredFonts.filter( ( font ) =>
|
|
13
|
+
font.name.toLowerCase().includes( search.toLowerCase() )
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return filteredFonts;
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function getFontsOutline( fonts ) {
|
|
2
|
+
return fonts.reduce(
|
|
3
|
+
( acc, font ) => ( {
|
|
4
|
+
...acc,
|
|
5
|
+
[ font.slug ]: ( font?.fontFace || [] ).reduce(
|
|
6
|
+
( faces, face ) => ( {
|
|
7
|
+
...faces,
|
|
8
|
+
[ `${ face.fontStyle }-${ face.fontWeight }` ]: true,
|
|
9
|
+
} ),
|
|
10
|
+
{}
|
|
11
|
+
),
|
|
12
|
+
} ),
|
|
13
|
+
{}
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isFontFontFaceInOutline( slug, face, outline ) {
|
|
18
|
+
return (
|
|
19
|
+
outline[ slug ]?.[ `${ face.fontStyle }-${ face.fontWeight }` ] || false
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { FONT_WEIGHTS, FONT_STYLES } from './constants';
|
|
5
|
+
import { formatFontFamily } from './preview-styles';
|
|
5
6
|
|
|
6
7
|
export function setUIValuesNeeded( font, extraValues = {} ) {
|
|
7
8
|
if ( ! font.name && ( font.fontFamily || font.slug ) ) {
|
|
@@ -84,10 +85,14 @@ export async function loadFontFaceInBrowser( fontFace, source, addTo = 'all' ) {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
// eslint-disable-next-line no-undef
|
|
87
|
-
const newFont = new FontFace(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
const newFont = new FontFace(
|
|
89
|
+
formatFontFamily( fontFace.fontFamily ),
|
|
90
|
+
dataSource,
|
|
91
|
+
{
|
|
92
|
+
style: fontFace.fontStyle,
|
|
93
|
+
weight: fontFace.fontWeight,
|
|
94
|
+
}
|
|
95
|
+
);
|
|
91
96
|
|
|
92
97
|
const loadedFace = await newFont.load();
|
|
93
98
|
|
|
@@ -120,71 +125,6 @@ export function getDisplaySrcFromFontFace( input, urlPrefix ) {
|
|
|
120
125
|
return src;
|
|
121
126
|
}
|
|
122
127
|
|
|
123
|
-
function findNearest( input, numbers ) {
|
|
124
|
-
// If the numbers array is empty, return null
|
|
125
|
-
if ( numbers.length === 0 ) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
// Sort the array based on the absolute difference with the input
|
|
129
|
-
numbers.sort( ( a, b ) => Math.abs( input - a ) - Math.abs( input - b ) );
|
|
130
|
-
// Return the first element (which will be the nearest) from the sorted array
|
|
131
|
-
return numbers[ 0 ];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function extractFontWeights( fontFaces ) {
|
|
135
|
-
const result = [];
|
|
136
|
-
|
|
137
|
-
fontFaces.forEach( ( face ) => {
|
|
138
|
-
const weights = String( face.fontWeight ).split( ' ' );
|
|
139
|
-
|
|
140
|
-
if ( weights.length === 2 ) {
|
|
141
|
-
const start = parseInt( weights[ 0 ] );
|
|
142
|
-
const end = parseInt( weights[ 1 ] );
|
|
143
|
-
|
|
144
|
-
for ( let i = start; i <= end; i += 100 ) {
|
|
145
|
-
result.push( i );
|
|
146
|
-
}
|
|
147
|
-
} else if ( weights.length === 1 ) {
|
|
148
|
-
result.push( parseInt( weights[ 0 ] ) );
|
|
149
|
-
}
|
|
150
|
-
} );
|
|
151
|
-
|
|
152
|
-
return result;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export function getPreviewStyle( family ) {
|
|
156
|
-
const style = { fontFamily: family.fontFamily };
|
|
157
|
-
|
|
158
|
-
if ( ! Array.isArray( family.fontFace ) ) {
|
|
159
|
-
style.fontWeight = '400';
|
|
160
|
-
style.fontStyle = 'normal';
|
|
161
|
-
return style;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if ( family.fontFace ) {
|
|
165
|
-
//get all the font faces with normal style
|
|
166
|
-
const normalFaces = family.fontFace.filter(
|
|
167
|
-
( face ) => face.fontStyle.toLowerCase() === 'normal'
|
|
168
|
-
);
|
|
169
|
-
if ( normalFaces.length > 0 ) {
|
|
170
|
-
style.fontStyle = 'normal';
|
|
171
|
-
const normalWeights = extractFontWeights( normalFaces );
|
|
172
|
-
const nearestWeight = findNearest( 400, normalWeights );
|
|
173
|
-
style.fontWeight = String( nearestWeight ) || '400';
|
|
174
|
-
} else {
|
|
175
|
-
style.fontStyle =
|
|
176
|
-
( family.fontFace.length && family.fontFace[ 0 ].fontStyle ) ||
|
|
177
|
-
'normal';
|
|
178
|
-
style.fontWeight =
|
|
179
|
-
( family.fontFace.length &&
|
|
180
|
-
String( family.fontFace[ 0 ].fontWeight ) ) ||
|
|
181
|
-
'400';
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return style;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
128
|
export function makeFormDataFromFontFamilies( fontFamilies ) {
|
|
189
129
|
const formData = new FormData();
|
|
190
130
|
const newFontFamilies = fontFamilies.map( ( family, familyIndex ) => {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
function findNearest( input, numbers ) {
|
|
2
|
+
// If the numbers array is empty, return null
|
|
3
|
+
if ( numbers.length === 0 ) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
// Sort the array based on the absolute difference with the input
|
|
7
|
+
numbers.sort( ( a, b ) => Math.abs( input - a ) - Math.abs( input - b ) );
|
|
8
|
+
// Return the first element (which will be the nearest) from the sorted array
|
|
9
|
+
return numbers[ 0 ];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function extractFontWeights( fontFaces ) {
|
|
13
|
+
const result = [];
|
|
14
|
+
|
|
15
|
+
fontFaces.forEach( ( face ) => {
|
|
16
|
+
const weights = String( face.fontWeight ).split( ' ' );
|
|
17
|
+
|
|
18
|
+
if ( weights.length === 2 ) {
|
|
19
|
+
const start = parseInt( weights[ 0 ] );
|
|
20
|
+
const end = parseInt( weights[ 1 ] );
|
|
21
|
+
|
|
22
|
+
for ( let i = start; i <= end; i += 100 ) {
|
|
23
|
+
result.push( i );
|
|
24
|
+
}
|
|
25
|
+
} else if ( weights.length === 1 ) {
|
|
26
|
+
result.push( parseInt( weights[ 0 ] ) );
|
|
27
|
+
}
|
|
28
|
+
} );
|
|
29
|
+
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function formatFontFamily( input ) {
|
|
34
|
+
return input
|
|
35
|
+
.split( ',' )
|
|
36
|
+
.map( ( font ) => {
|
|
37
|
+
font = font.trim(); // Remove any leading or trailing white spaces
|
|
38
|
+
// If the font doesn't have single quotes and contains a space, then add single quotes around it
|
|
39
|
+
if ( ! font.startsWith( "'" ) && font.indexOf( ' ' ) !== -1 ) {
|
|
40
|
+
return `'${ font }'`;
|
|
41
|
+
}
|
|
42
|
+
return font; // Return font as is if no transformation is needed
|
|
43
|
+
} )
|
|
44
|
+
.join( ', ' );
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function getFamilyPreviewStyle( family ) {
|
|
48
|
+
const style = { fontFamily: formatFontFamily( family.fontFamily ) };
|
|
49
|
+
|
|
50
|
+
if ( ! Array.isArray( family.fontFace ) ) {
|
|
51
|
+
style.fontWeight = '400';
|
|
52
|
+
style.fontStyle = 'normal';
|
|
53
|
+
return style;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if ( family.fontFace ) {
|
|
57
|
+
//get all the font faces with normal style
|
|
58
|
+
const normalFaces = family.fontFace.filter(
|
|
59
|
+
( face ) => face.fontStyle.toLowerCase() === 'normal'
|
|
60
|
+
);
|
|
61
|
+
if ( normalFaces.length > 0 ) {
|
|
62
|
+
style.fontStyle = 'normal';
|
|
63
|
+
const normalWeights = extractFontWeights( normalFaces );
|
|
64
|
+
const nearestWeight = findNearest( 400, normalWeights );
|
|
65
|
+
style.fontWeight = String( nearestWeight ) || '400';
|
|
66
|
+
} else {
|
|
67
|
+
style.fontStyle =
|
|
68
|
+
( family.fontFace.length && family.fontFace[ 0 ].fontStyle ) ||
|
|
69
|
+
'normal';
|
|
70
|
+
style.fontWeight =
|
|
71
|
+
( family.fontFace.length &&
|
|
72
|
+
String( family.fontFace[ 0 ].fontWeight ) ) ||
|
|
73
|
+
'400';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return style;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function getFacePreviewStyle( face ) {
|
|
81
|
+
return {
|
|
82
|
+
fontFamily: formatFontFamily( face.fontFamily ),
|
|
83
|
+
fontStyle: face.fontStyle || 'normal',
|
|
84
|
+
fontWeight: face.fontWeight || '400',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function getNumericFontWeight( value ) {
|
|
2
|
+
switch ( value ) {
|
|
3
|
+
case 'normal':
|
|
4
|
+
return 400;
|
|
5
|
+
case 'bold':
|
|
6
|
+
return 700;
|
|
7
|
+
case 'bolder':
|
|
8
|
+
return 500;
|
|
9
|
+
case 'lighter':
|
|
10
|
+
return 300;
|
|
11
|
+
default:
|
|
12
|
+
return parseInt( value, 10 );
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function sortFontFaces( faces ) {
|
|
17
|
+
return faces.sort( ( a, b ) => {
|
|
18
|
+
// Ensure 'normal' fontStyle is always first
|
|
19
|
+
if ( a.fontStyle === 'normal' && b.fontStyle !== 'normal' ) return -1;
|
|
20
|
+
if ( b.fontStyle === 'normal' && a.fontStyle !== 'normal' ) return 1;
|
|
21
|
+
|
|
22
|
+
// If both fontStyles are the same, sort by fontWeight
|
|
23
|
+
if ( a.fontStyle === b.fontStyle ) {
|
|
24
|
+
return (
|
|
25
|
+
getNumericFontWeight( a.fontWeight ) -
|
|
26
|
+
getNumericFontWeight( b.fontWeight )
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Sort other fontStyles alphabetically
|
|
31
|
+
return a.fontStyle.localeCompare( b.fontStyle );
|
|
32
|
+
} );
|
|
33
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import filterFonts from '../filter-fonts';
|
|
5
|
+
|
|
6
|
+
describe( 'filterFonts', () => {
|
|
7
|
+
const mockFonts = [
|
|
8
|
+
{ name: 'Arial', category: 'sans-serif' },
|
|
9
|
+
{ name: 'Arial Condensed', category: 'sans-serif' },
|
|
10
|
+
{ name: 'Times New Roman', category: 'serif' },
|
|
11
|
+
{ name: 'Courier New', category: 'monospace' },
|
|
12
|
+
{ name: 'Romantic', category: 'cursive' },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
it( 'should return all fonts if no filters are provided', () => {
|
|
16
|
+
const result = filterFonts( mockFonts, {} );
|
|
17
|
+
expect( result ).toEqual( mockFonts );
|
|
18
|
+
} );
|
|
19
|
+
|
|
20
|
+
it( 'should filter by category', () => {
|
|
21
|
+
const result = filterFonts( mockFonts, { category: 'serif' } );
|
|
22
|
+
expect( result ).toEqual( [
|
|
23
|
+
{ name: 'Times New Roman', category: 'serif' },
|
|
24
|
+
] );
|
|
25
|
+
} );
|
|
26
|
+
|
|
27
|
+
it( 'should return all fonts if category is "all"', () => {
|
|
28
|
+
const result = filterFonts( mockFonts, { category: 'all' } );
|
|
29
|
+
expect( result ).toEqual( mockFonts );
|
|
30
|
+
} );
|
|
31
|
+
|
|
32
|
+
it( 'should filter by search', () => {
|
|
33
|
+
const result = filterFonts( mockFonts, { search: 'ari' } );
|
|
34
|
+
expect( result ).toEqual( [
|
|
35
|
+
{ name: 'Arial', category: 'sans-serif' },
|
|
36
|
+
{ name: 'Arial Condensed', category: 'sans-serif' },
|
|
37
|
+
] );
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
it( 'should be case insensitive when filtering by search', () => {
|
|
41
|
+
const result = filterFonts( mockFonts, { search: 'RoMANtic' } );
|
|
42
|
+
expect( result ).toEqual( [
|
|
43
|
+
{ name: 'Romantic', category: 'cursive' },
|
|
44
|
+
] );
|
|
45
|
+
} );
|
|
46
|
+
|
|
47
|
+
it( 'should filter by both category and search', () => {
|
|
48
|
+
const result = filterFonts( mockFonts, {
|
|
49
|
+
category: 'serif',
|
|
50
|
+
search: 'Times',
|
|
51
|
+
} );
|
|
52
|
+
expect( result ).toEqual( [
|
|
53
|
+
{ name: 'Times New Roman', category: 'serif' },
|
|
54
|
+
] );
|
|
55
|
+
} );
|
|
56
|
+
|
|
57
|
+
it( 'should return an empty array if no fonts match the filter criteria', () => {
|
|
58
|
+
const result = filterFonts( mockFonts, {
|
|
59
|
+
category: 'serif',
|
|
60
|
+
search: 'Arial',
|
|
61
|
+
} );
|
|
62
|
+
expect( result ).toEqual( [] );
|
|
63
|
+
} );
|
|
64
|
+
|
|
65
|
+
it( 'should return an empty array if fonts array is not provided', () => {
|
|
66
|
+
const result = filterFonts( undefined, { category: 'serif' } );
|
|
67
|
+
expect( result ).toEqual( [] );
|
|
68
|
+
} );
|
|
69
|
+
} );
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getFontsOutline, isFontFontFaceInOutline } from '../fonts-outline';
|
|
5
|
+
|
|
6
|
+
describe( 'getFontsOutline', () => {
|
|
7
|
+
test( 'should return an empty object for an empty fonts array', () => {
|
|
8
|
+
const fonts = [];
|
|
9
|
+
const result = getFontsOutline( fonts );
|
|
10
|
+
expect( result ).toEqual( {} );
|
|
11
|
+
} );
|
|
12
|
+
|
|
13
|
+
test( 'should handle fonts with no fontFace property', () => {
|
|
14
|
+
const fonts = [
|
|
15
|
+
{ slug: 'font1' },
|
|
16
|
+
{
|
|
17
|
+
slug: 'font2',
|
|
18
|
+
fontFace: [ { fontStyle: 'normal', fontWeight: '400' } ],
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
const result = getFontsOutline( fonts );
|
|
22
|
+
expect( result ).toEqual( {
|
|
23
|
+
font1: {},
|
|
24
|
+
font2: { 'normal-400': true },
|
|
25
|
+
} );
|
|
26
|
+
} );
|
|
27
|
+
|
|
28
|
+
test( 'should handle fonts with an empty fontFace array', () => {
|
|
29
|
+
const fonts = [ { slug: 'font1', fontFace: [] } ];
|
|
30
|
+
const result = getFontsOutline( fonts );
|
|
31
|
+
expect( result ).toEqual( {
|
|
32
|
+
font1: {},
|
|
33
|
+
} );
|
|
34
|
+
} );
|
|
35
|
+
|
|
36
|
+
test( 'should handle fonts with multiple font faces', () => {
|
|
37
|
+
const fonts = [
|
|
38
|
+
{
|
|
39
|
+
slug: 'font1',
|
|
40
|
+
fontFace: [
|
|
41
|
+
{ fontStyle: 'normal', fontWeight: '400' },
|
|
42
|
+
{ fontStyle: 'italic', fontWeight: '700' },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
const result = getFontsOutline( fonts );
|
|
47
|
+
expect( result ).toEqual( {
|
|
48
|
+
font1: {
|
|
49
|
+
'normal-400': true,
|
|
50
|
+
'italic-700': true,
|
|
51
|
+
},
|
|
52
|
+
} );
|
|
53
|
+
} );
|
|
54
|
+
} );
|
|
55
|
+
|
|
56
|
+
describe( 'isFontFontFaceInOutline', () => {
|
|
57
|
+
test( 'should return false for an empty outline', () => {
|
|
58
|
+
const slug = 'font1';
|
|
59
|
+
const face = { fontStyle: 'normal', fontWeight: '400' };
|
|
60
|
+
const outline = {};
|
|
61
|
+
|
|
62
|
+
const result = isFontFontFaceInOutline( slug, face, outline );
|
|
63
|
+
|
|
64
|
+
expect( result ).toBe( false );
|
|
65
|
+
} );
|
|
66
|
+
|
|
67
|
+
test( 'should return false when outline has the slug but no matching fontStyle-fontWeight', () => {
|
|
68
|
+
const slug = 'font1';
|
|
69
|
+
const face = { fontStyle: 'normal', fontWeight: '400' };
|
|
70
|
+
const outline = {
|
|
71
|
+
font1: {
|
|
72
|
+
'italic-700': true,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const result = isFontFontFaceInOutline( slug, face, outline );
|
|
77
|
+
|
|
78
|
+
expect( result ).toBe( false );
|
|
79
|
+
} );
|
|
80
|
+
|
|
81
|
+
test( 'should return false when outline does not have the slug', () => {
|
|
82
|
+
const slug = 'font1';
|
|
83
|
+
const face = { fontStyle: 'normal', fontWeight: '400' };
|
|
84
|
+
const outline = {
|
|
85
|
+
font2: {
|
|
86
|
+
'normal-400': true,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const result = isFontFontFaceInOutline( slug, face, outline );
|
|
91
|
+
|
|
92
|
+
expect( result ).toBe( false );
|
|
93
|
+
} );
|
|
94
|
+
|
|
95
|
+
test( 'should return true when outline has the slug and the matching fontStyle-fontWeight', () => {
|
|
96
|
+
const slug = 'font1';
|
|
97
|
+
const face = { fontStyle: 'normal', fontWeight: '400' };
|
|
98
|
+
const outline = {
|
|
99
|
+
font1: {
|
|
100
|
+
'normal-400': true,
|
|
101
|
+
'italic-700': true,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const result = isFontFontFaceInOutline( slug, face, outline );
|
|
106
|
+
|
|
107
|
+
expect( result ).toBe( true );
|
|
108
|
+
} );
|
|
109
|
+
} );
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { getFamilyPreviewStyle, formatFontFamily } from '../preview-styles';
|
|
5
5
|
|
|
6
|
-
describe( '
|
|
6
|
+
describe( 'getFamilyPreviewStyle', () => {
|
|
7
7
|
it( 'should return default fontStyle and fontWeight if fontFace is not provided', () => {
|
|
8
8
|
const family = { fontFamily: 'Rosario' };
|
|
9
|
-
const result =
|
|
9
|
+
const result = getFamilyPreviewStyle( family );
|
|
10
10
|
const expected = {
|
|
11
11
|
fontFamily: 'Rosario',
|
|
12
12
|
fontWeight: '400',
|
|
@@ -23,7 +23,7 @@ describe( 'getPreviewStyle', () => {
|
|
|
23
23
|
{ fontStyle: 'normal', fontWeight: '600' },
|
|
24
24
|
],
|
|
25
25
|
};
|
|
26
|
-
const result =
|
|
26
|
+
const result = getFamilyPreviewStyle( family );
|
|
27
27
|
const expected = {
|
|
28
28
|
fontFamily: 'Rosario',
|
|
29
29
|
fontStyle: 'normal',
|
|
@@ -40,7 +40,7 @@ describe( 'getPreviewStyle', () => {
|
|
|
40
40
|
{ fontStyle: 'italic', fontWeight: '600' },
|
|
41
41
|
],
|
|
42
42
|
};
|
|
43
|
-
const result =
|
|
43
|
+
const result = getFamilyPreviewStyle( family );
|
|
44
44
|
const expected = {
|
|
45
45
|
fontFamily: 'Rosario',
|
|
46
46
|
fontStyle: 'italic',
|
|
@@ -57,7 +57,7 @@ describe( 'getPreviewStyle', () => {
|
|
|
57
57
|
{ fontStyle: 'normal', fontWeight: '700' },
|
|
58
58
|
],
|
|
59
59
|
};
|
|
60
|
-
const result =
|
|
60
|
+
const result = getFamilyPreviewStyle( family );
|
|
61
61
|
const expected = {
|
|
62
62
|
fontFamily: 'Rosario',
|
|
63
63
|
fontStyle: 'normal',
|
|
@@ -74,7 +74,7 @@ describe( 'getPreviewStyle', () => {
|
|
|
74
74
|
{ fontStyle: 'normal', fontWeight: '400' },
|
|
75
75
|
],
|
|
76
76
|
};
|
|
77
|
-
const result =
|
|
77
|
+
const result = getFamilyPreviewStyle( family );
|
|
78
78
|
const expected = {
|
|
79
79
|
fontFamily: 'Rosario',
|
|
80
80
|
fontStyle: 'normal',
|
|
@@ -92,7 +92,7 @@ describe( 'getPreviewStyle', () => {
|
|
|
92
92
|
{ fontStyle: 'normal', fontWeight: '600' },
|
|
93
93
|
],
|
|
94
94
|
};
|
|
95
|
-
const result =
|
|
95
|
+
const result = getFamilyPreviewStyle( family );
|
|
96
96
|
const expected = {
|
|
97
97
|
fontFamily: 'Rosario',
|
|
98
98
|
fontStyle: 'normal',
|
|
@@ -110,7 +110,7 @@ describe( 'getPreviewStyle', () => {
|
|
|
110
110
|
{ fontStyle: 'italic', fontWeight: '200 900' },
|
|
111
111
|
],
|
|
112
112
|
};
|
|
113
|
-
const result =
|
|
113
|
+
const result = getFamilyPreviewStyle( family );
|
|
114
114
|
const expected = {
|
|
115
115
|
fontFamily: 'Rosario',
|
|
116
116
|
fontStyle: 'normal',
|
|
@@ -119,3 +119,43 @@ describe( 'getPreviewStyle', () => {
|
|
|
119
119
|
expect( result ).toEqual( expected );
|
|
120
120
|
} );
|
|
121
121
|
} );
|
|
122
|
+
|
|
123
|
+
describe( 'formatFontFamily', () => {
|
|
124
|
+
it( 'should transform "Baloo 2, system-ui" correctly', () => {
|
|
125
|
+
expect( formatFontFamily( 'Baloo 2, system-ui' ) ).toBe(
|
|
126
|
+
"'Baloo 2', system-ui"
|
|
127
|
+
);
|
|
128
|
+
} );
|
|
129
|
+
|
|
130
|
+
it( 'should ignore extra spaces', () => {
|
|
131
|
+
expect( formatFontFamily( ' Baloo 2 , system-ui' ) ).toBe(
|
|
132
|
+
"'Baloo 2', system-ui"
|
|
133
|
+
);
|
|
134
|
+
} );
|
|
135
|
+
|
|
136
|
+
it( 'should keep quoted strings unchanged', () => {
|
|
137
|
+
expect(
|
|
138
|
+
formatFontFamily(
|
|
139
|
+
"Seravek, 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', source-sans-pro, sans-serif"
|
|
140
|
+
)
|
|
141
|
+
).toBe(
|
|
142
|
+
"Seravek, 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', source-sans-pro, sans-serif"
|
|
143
|
+
);
|
|
144
|
+
} );
|
|
145
|
+
|
|
146
|
+
it( 'should wrap single font name with spaces in quotes', () => {
|
|
147
|
+
expect( formatFontFamily( 'Baloo 2' ) ).toBe( "'Baloo 2'" );
|
|
148
|
+
} );
|
|
149
|
+
|
|
150
|
+
it( 'should wrap multiple font names with spaces in quotes', () => {
|
|
151
|
+
expect( formatFontFamily( 'Baloo Bhai 2, Baloo 2' ) ).toBe(
|
|
152
|
+
"'Baloo Bhai 2', 'Baloo 2'"
|
|
153
|
+
);
|
|
154
|
+
} );
|
|
155
|
+
|
|
156
|
+
it( 'should wrap only those font names with spaces which are not already quoted', () => {
|
|
157
|
+
expect( formatFontFamily( 'Baloo Bhai 2, Arial' ) ).toBe(
|
|
158
|
+
"'Baloo Bhai 2', Arial"
|
|
159
|
+
);
|
|
160
|
+
} );
|
|
161
|
+
} );
|