@wordpress/edit-site 5.18.1-next.5a1d1283.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/CHANGELOG.md +2 -0
- package/build/components/add-new-pattern/index.js +65 -4
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-template/index.js +3 -2
- package/build/components/add-new-template/index.js.map +1 -1
- package/build/components/add-new-template/new-template.js +6 -1
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +6 -1
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/app/index.js +2 -7
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/back-button.js +3 -2
- package/build/components/block-editor/back-button.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/editor-canvas.js +20 -16
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- 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 +2 -4
- package/build/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +8 -4
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/canvas-loader/index.js +18 -1
- package/build/components/canvas-loader/index.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 +7 -9
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +5 -4
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/font-families.js +68 -0
- package/build/components/global-styles/font-families.js.map +1 -0
- package/build/components/global-styles/font-family-item.js +47 -0
- package/build/components/global-styles/font-family-item.js.map +1 -0
- 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/confirm-delete-dialog.js +31 -0
- package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +1 -0
- package/build/components/global-styles/font-library-modal/context.js +309 -0
- package/build/components/global-styles/font-library-modal/context.js.map +1 -0
- package/build/components/global-styles/font-library-modal/font-card.js +61 -0
- package/build/components/global-styles/font-library-modal/font-card.js.map +1 -0
- 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 +86 -0
- package/build/components/global-styles/font-library-modal/font-demo.js.map +1 -0
- package/build/components/global-styles/font-library-modal/font-variant.js +51 -0
- package/build/components/global-styles/font-library-modal/font-variant.js.map +1 -0
- package/build/components/global-styles/font-library-modal/fonts-grid.js +54 -0
- package/build/components/global-styles/font-library-modal/fonts-grid.js.map +1 -0
- 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 +65 -0
- package/build/components/global-styles/font-library-modal/index.js.map +1 -0
- package/build/components/global-styles/font-library-modal/installed-fonts.js +128 -0
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -0
- package/build/components/global-styles/font-library-modal/library-font-card.js +39 -0
- package/build/components/global-styles/font-library-modal/library-font-card.js.map +1 -0
- package/build/components/global-styles/font-library-modal/library-font-details.js +44 -0
- package/build/components/global-styles/font-library-modal/library-font-details.js.map +1 -0
- package/build/components/global-styles/font-library-modal/library-font-variant.js +59 -0
- package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -0
- package/build/components/global-styles/font-library-modal/local-fonts.js +143 -0
- package/build/components/global-styles/font-library-modal/local-fonts.js.map +1 -0
- package/build/components/global-styles/font-library-modal/resolvers.js +53 -0
- package/build/components/global-styles/font-library-modal/resolvers.js.map +1 -0
- package/build/components/global-styles/font-library-modal/tab-layout.js +45 -0
- package/build/components/global-styles/font-library-modal/tab-layout.js.map +1 -0
- package/build/components/global-styles/font-library-modal/utils/constants.js +31 -0
- package/build/components/global-styles/font-library-modal/utils/constants.js.map +1 -0
- 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/get-intersecting-font-faces.js +58 -0
- package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +1 -0
- package/build/components/global-styles/font-library-modal/utils/index.js +155 -0
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -0
- package/build/components/global-styles/font-library-modal/utils/make-families-from-faces.js +22 -0
- package/build/components/global-styles/font-library-modal/utils/make-families-from-faces.js.map +1 -0
- 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/font-library-modal/utils/toggleFont.js +92 -0
- package/build/components/global-styles/font-library-modal/utils/toggleFont.js.map +1 -0
- package/build/components/global-styles/global-styles-provider.js +7 -12
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/screen-block.js +34 -21
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +1 -3
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +0 -1
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +4 -72
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +3 -5
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/typogrphy-elements.js +96 -0
- package/build/components/global-styles/typogrphy-elements.js.map +1 -0
- 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 +56 -20
- package/build/components/page-patterns/duplicate-menu-item.js.map +1 -1
- package/build/components/page-patterns/grid-item.js +48 -22
- package/build/components/page-patterns/grid-item.js.map +1 -1
- package/build/components/page-patterns/header.js +3 -7
- package/build/components/page-patterns/header.js.map +1 -1
- package/build/components/page-patterns/index.js +3 -3
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/patterns-list.js +7 -7
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/rename-menu-item.js +6 -5
- package/build/components/page-patterns/rename-menu-item.js.map +1 -1
- package/build/components/page-patterns/search-items.js +8 -2
- package/build/components/page-patterns/search-items.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +71 -51
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-patterns/utils.js +1 -20
- package/build/components/page-patterns/utils.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 +53 -26
- package/build/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/hooks.js +65 -0
- package/build/components/sidebar-edit-mode/page-panels/hooks.js.map +1 -0
- package/build/components/sidebar-edit-mode/page-panels/index.js +1 -4
- package/build/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js +2 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js +56 -0
- package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -0
- package/build/components/sidebar-edit-mode/page-panels/swap-template-button.js +91 -0
- package/build/components/sidebar-edit-mode/page-panels/swap-template-button.js.map +1 -0
- 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/index.js +11 -9
- package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/last-revision.js +6 -4
- package/build/components/sidebar-edit-mode/template-panel/last-revision.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/pattern-categories.js +218 -0
- package/build/components/sidebar-edit-mode/template-panel/pattern-categories.js.map +1 -0
- package/build/components/sidebar-navigation-screen/index.js +6 -4
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-details-footer/index.js +32 -4
- package/build/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js +4 -2
- package/build/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +4 -31
- package/build/components/sidebar-navigation-screen-global-styles/index.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/index.js +3 -3
- package/build/components/sidebar-navigation-screen-page/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 +20 -9
- 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 +41 -11
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +9 -37
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +44 -5
- 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-patterns/use-theme-patterns.js +2 -1
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.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-template/index.js +2 -2
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +5 -4
- 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 +8 -4
- package/build/components/template-actions/index.js.map +1 -1
- package/build/components/template-actions/rename-menu-item.js +9 -3
- package/build/components/template-actions/rename-menu-item.js.map +1 -1
- package/build/components/welcome-guide/styles.js +2 -2
- package/build/components/welcome-guide/styles.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/push-changes-to-global-styles/index.js +5 -37
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/hooks/template-part-edit.js +2 -1
- package/build/hooks/template-part-edit.js.map +1 -1
- package/build/store/actions.js +38 -14
- 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 +64 -2
- package/build/utils/constants.js.map +1 -1
- package/build/utils/is-template-removable.js +6 -1
- package/build/utils/is-template-removable.js.map +1 -1
- package/build/utils/is-template-revertable.js +6 -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 +69 -8
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-template/index.js +3 -2
- package/build-module/components/add-new-template/index.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +6 -1
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +6 -1
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/app/index.js +2 -7
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/back-button.js +3 -2
- package/build-module/components/block-editor/back-button.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/editor-canvas.js +21 -17
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- 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 +5 -7
- package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +8 -4
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/canvas-loader/index.js +18 -1
- package/build-module/components/canvas-loader/index.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 +7 -9
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +5 -4
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +58 -0
- package/build-module/components/global-styles/font-families.js.map +1 -0
- package/build-module/components/global-styles/font-family-item.js +40 -0
- package/build-module/components/global-styles/font-family-item.js.map +1 -0
- 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/confirm-delete-dialog.js +23 -0
- package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/context.js +300 -0
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/font-card.js +52 -0
- package/build-module/components/global-styles/font-library-modal/font-card.js.map +1 -0
- 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 +79 -0
- package/build-module/components/global-styles/font-library-modal/font-demo.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/font-variant.js +42 -0
- package/build-module/components/global-styles/font-library-modal/font-variant.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/fonts-grid.js +47 -0
- package/build-module/components/global-styles/font-library-modal/fonts-grid.js.map +1 -0
- 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 +57 -0
- package/build-module/components/global-styles/font-library-modal/index.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +120 -0
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/library-font-card.js +31 -0
- package/build-module/components/global-styles/font-library-modal/library-font-card.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/library-font-details.js +35 -0
- package/build-module/components/global-styles/font-library-modal/library-font-details.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js +50 -0
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/local-fonts.js +135 -0
- package/build-module/components/global-styles/font-library-modal/local-fonts.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/resolvers.js +42 -0
- package/build-module/components/global-styles/font-library-modal/resolvers.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/tab-layout.js +37 -0
- package/build-module/components/global-styles/font-library-modal/tab-layout.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/utils/constants.js +21 -0
- package/build-module/components/global-styles/font-library-modal/utils/constants.js.map +1 -0
- 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/get-intersecting-font-faces.js +52 -0
- package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/utils/index.js +141 -0
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/utils/make-families-from-faces.js +16 -0
- package/build-module/components/global-styles/font-library-modal/utils/make-families-from-faces.js.map +1 -0
- 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/font-library-modal/utils/toggleFont.js +86 -0
- package/build-module/components/global-styles/font-library-modal/utils/toggleFont.js.map +1 -0
- package/build-module/components/global-styles/global-styles-provider.js +7 -12
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +34 -21
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +1 -3
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +0 -1
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +6 -74
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +3 -5
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/typogrphy-elements.js +87 -0
- package/build-module/components/global-styles/typogrphy-elements.js.map +1 -0
- 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 +55 -20
- package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -1
- package/build-module/components/page-patterns/grid-item.js +49 -23
- package/build-module/components/page-patterns/grid-item.js.map +1 -1
- package/build-module/components/page-patterns/header.js +3 -7
- package/build-module/components/page-patterns/header.js.map +1 -1
- package/build-module/components/page-patterns/index.js +3 -3
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/patterns-list.js +7 -7
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/rename-menu-item.js +6 -5
- package/build-module/components/page-patterns/rename-menu-item.js.map +1 -1
- package/build-module/components/page-patterns/search-items.js +8 -2
- package/build-module/components/page-patterns/search-items.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +71 -52
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-patterns/utils.js +0 -11
- package/build-module/components/page-patterns/utils.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 +54 -29
- 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 +55 -0
- package/build-module/components/sidebar-edit-mode/page-panels/hooks.js.map +1 -0
- package/build-module/components/sidebar-edit-mode/page-panels/index.js +1 -4
- package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js +2 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js +49 -0
- package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -0
- package/build-module/components/sidebar-edit-mode/page-panels/swap-template-button.js +85 -0
- package/build-module/components/sidebar-edit-mode/page-panels/swap-template-button.js.map +1 -0
- 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/index.js +12 -10
- package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/last-revision.js +8 -6
- package/build-module/components/sidebar-edit-mode/template-panel/last-revision.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/pattern-categories.js +209 -0
- package/build-module/components/sidebar-edit-mode/template-panel/pattern-categories.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen/index.js +6 -4
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-details-footer/index.js +32 -5
- package/build-module/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js +4 -2
- package/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +6 -33
- package/build-module/components/sidebar-navigation-screen-global-styles/index.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/index.js +3 -3
- package/build-module/components/sidebar-navigation-screen-page/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 +21 -10
- 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 +41 -11
- 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 +12 -40
- 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 +44 -5
- 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-patterns/use-theme-patterns.js +3 -2
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.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-template/index.js +2 -2
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +5 -4
- 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 +8 -4
- package/build-module/components/template-actions/index.js.map +1 -1
- package/build-module/components/template-actions/rename-menu-item.js +9 -3
- package/build-module/components/template-actions/rename-menu-item.js.map +1 -1
- package/build-module/components/welcome-guide/styles.js +2 -2
- package/build-module/components/welcome-guide/styles.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/push-changes-to-global-styles/index.js +5 -37
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +2 -1
- package/build-module/hooks/template-part-edit.js.map +1 -1
- package/build-module/store/actions.js +39 -16
- 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 +51 -1
- package/build-module/utils/constants.js.map +1 -1
- package/build-module/utils/is-template-removable.js +6 -1
- package/build-module/utils/is-template-removable.js.map +1 -1
- package/build-module/utils/is-template-revertable.js +6 -1
- 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 +267 -37
- package/build-style/style.css +267 -37
- package/lib/inflate.js +4082 -0
- package/lib/lib-font.browser.js +3831 -0
- package/lib/unbrotli.js +2679 -0
- package/package.json +40 -40
- package/src/components/add-new-pattern/index.js +86 -8
- package/src/components/add-new-template/index.js +3 -2
- package/src/components/add-new-template/new-template.js +6 -1
- package/src/components/add-new-template/utils.js +12 -3
- package/src/components/app/index.js +9 -12
- package/src/components/block-editor/back-button.js +6 -2
- 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/editor-canvas.js +31 -19
- package/src/components/block-editor/index.js +1 -14
- package/src/components/block-editor/site-editor-canvas.js +7 -12
- package/src/components/block-editor/style.scss +88 -1
- package/src/components/block-editor/use-site-editor-settings.js +26 -19
- package/src/components/canvas-loader/index.js +12 -1
- package/src/components/canvas-loader/style.scss +1 -1
- package/src/components/create-template-part-modal/index.js +11 -12
- package/src/components/editor/index.js +9 -10
- package/src/components/global-styles/dimensions-panel.js +8 -4
- package/src/components/global-styles/font-families.js +71 -0
- package/src/components/global-styles/font-family-item.js +44 -0
- 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/confirm-delete-dialog.js +33 -0
- package/src/components/global-styles/font-library-modal/context.js +378 -0
- package/src/components/global-styles/font-library-modal/font-card.js +75 -0
- package/src/components/global-styles/font-library-modal/font-collection.js +257 -0
- package/src/components/global-styles/font-library-modal/font-demo.js +83 -0
- package/src/components/global-styles/font-library-modal/font-variant.js +53 -0
- package/src/components/global-styles/font-library-modal/fonts-grid.js +55 -0
- 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 +67 -0
- package/src/components/global-styles/font-library-modal/installed-fonts.js +174 -0
- package/src/components/global-styles/font-library-modal/library-font-card.js +33 -0
- package/src/components/global-styles/font-library-modal/library-font-details.js +45 -0
- package/src/components/global-styles/font-library-modal/library-font-variant.js +54 -0
- package/src/components/global-styles/font-library-modal/local-fonts.js +160 -0
- package/src/components/global-styles/font-library-modal/resolvers.js +45 -0
- package/src/components/global-styles/font-library-modal/style.scss +139 -0
- package/src/components/global-styles/font-library-modal/tab-layout.js +50 -0
- package/src/components/global-styles/font-library-modal/utils/constants.js +23 -0
- 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/get-intersecting-font-faces.js +58 -0
- package/src/components/global-styles/font-library-modal/utils/index.js +153 -0
- package/src/components/global-styles/font-library-modal/utils/make-families-from-faces.js +15 -0
- 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/getDisplaySrcFromFontFace.spec.js +53 -0
- package/src/components/global-styles/font-library-modal/utils/test/getFontFaceVariantName.spec.js +30 -0
- package/src/components/global-styles/font-library-modal/utils/test/getIntersectingFontFaces.spec.js +240 -0
- package/src/components/global-styles/font-library-modal/utils/test/isUrlEncoded.spec.js +31 -0
- package/src/components/global-styles/font-library-modal/utils/test/makeFamiliesFromFaces.spec.js +57 -0
- package/src/components/global-styles/font-library-modal/utils/test/makeFormDataFromFontFamilies.spec.js +62 -0
- package/src/components/global-styles/font-library-modal/utils/test/mergeFontFaces.spec.js +56 -0
- package/src/components/global-styles/font-library-modal/utils/test/mergeFontFamilies.spec.js +108 -0
- package/src/components/global-styles/font-library-modal/utils/test/preview-styles.spec.js +161 -0
- package/src/components/global-styles/font-library-modal/utils/test/setUIValuesNeeded.spec.js +41 -0
- package/src/components/global-styles/font-library-modal/utils/test/sort-font-faces.js +74 -0
- package/src/components/global-styles/font-library-modal/utils/test/toggleFont.spec.js +141 -0
- package/src/components/global-styles/font-library-modal/utils/toggleFont.js +90 -0
- package/src/components/global-styles/global-styles-provider.js +2 -7
- package/src/components/global-styles/screen-block.js +42 -20
- package/src/components/global-styles/screen-revisions/index.js +0 -2
- package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +0 -1
- package/src/components/global-styles/screen-typography.js +9 -95
- package/src/components/global-styles/style-variations-container.js +0 -2
- package/src/components/global-styles/typogrphy-elements.js +110 -0
- 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/list/style.scss +2 -0
- package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +2 -8
- package/src/components/page-patterns/duplicate-menu-item.js +67 -24
- package/src/components/page-patterns/grid-item.js +80 -33
- package/src/components/page-patterns/header.js +3 -12
- package/src/components/page-patterns/index.js +3 -3
- package/src/components/page-patterns/patterns-list.js +7 -7
- package/src/components/page-patterns/rename-menu-item.js +18 -7
- package/src/components/page-patterns/search-items.js +20 -2
- package/src/components/page-patterns/style.scss +1 -5
- package/src/components/page-patterns/use-patterns.js +217 -127
- package/src/components/page-patterns/utils.js +0 -19
- 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 +94 -52
- package/src/components/sidebar-edit-mode/page-panels/hooks.js +88 -0
- package/src/components/sidebar-edit-mode/page-panels/index.js +0 -4
- package/src/components/sidebar-edit-mode/page-panels/page-summary.js +2 -0
- package/src/components/sidebar-edit-mode/page-panels/reset-default-template.js +44 -0
- package/src/components/sidebar-edit-mode/page-panels/style.scss +46 -9
- package/src/components/sidebar-edit-mode/page-panels/swap-template-button.js +82 -0
- package/src/components/sidebar-edit-mode/settings-header/index.js +4 -7
- package/src/components/sidebar-edit-mode/template-panel/index.js +28 -24
- package/src/components/sidebar-edit-mode/template-panel/last-revision.js +19 -15
- package/src/components/sidebar-edit-mode/template-panel/pattern-categories.js +277 -0
- package/src/components/sidebar-navigation-screen/index.js +4 -9
- package/src/components/sidebar-navigation-screen/style.scss +7 -1
- package/src/components/sidebar-navigation-screen-details-footer/index.js +38 -10
- package/src/components/sidebar-navigation-screen-details-footer/style.scss +10 -3
- package/src/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js +2 -0
- package/src/components/sidebar-navigation-screen-global-styles/index.js +6 -44
- 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-navigation-menus/style.scss +0 -4
- package/src/components/sidebar-navigation-screen-page/index.js +3 -3
- 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 +22 -8
- package/src/components/sidebar-navigation-screen-pattern/style.scss +0 -3
- 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 +63 -20
- package/src/components/sidebar-navigation-screen-patterns/index.js +20 -51
- package/src/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +61 -6
- package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +12 -2
- package/src/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +3 -5
- package/src/components/sidebar-navigation-screen-template/home-template-details.js +2 -1
- package/src/components/sidebar-navigation-screen-template/index.js +2 -4
- package/src/components/sidebar-navigation-screen-templates/index.js +5 -4
- 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 +15 -8
- package/src/components/template-actions/rename-menu-item.js +21 -5
- package/src/components/welcome-guide/styles.js +2 -2
- package/src/hooks/commands/use-edit-mode-commands.js +4 -3
- package/src/hooks/navigation-menu-edit.js +2 -1
- package/src/hooks/push-changes-to-global-styles/index.js +6 -49
- package/src/hooks/template-part-edit.js +2 -1
- package/src/store/actions.js +56 -22
- 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/style.scss +1 -1
- package/src/utils/constants.js +54 -3
- package/src/utils/is-template-removable.js +8 -1
- package/src/utils/is-template-revertable.js +8 -1
- 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/components/sidebar-navigation-screen-patterns/use-my-patterns.js +0 -30
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.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/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js +0 -23
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.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
- package/src/components/sidebar-navigation-screen-global-styles/style.scss +0 -12
- package/src/components/sidebar-navigation-screen-patterns/use-my-patterns.js +0 -24
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = filterFonts;
|
|
7
|
+
function filterFonts(fonts, filters) {
|
|
8
|
+
const {
|
|
9
|
+
category,
|
|
10
|
+
search
|
|
11
|
+
} = filters;
|
|
12
|
+
let filteredFonts = fonts || [];
|
|
13
|
+
if (category && category !== 'all') {
|
|
14
|
+
filteredFonts = filteredFonts.filter(font => font.category === category);
|
|
15
|
+
}
|
|
16
|
+
if (search) {
|
|
17
|
+
filteredFonts = filteredFonts.filter(font => font.name.toLowerCase().includes(search.toLowerCase()));
|
|
18
|
+
}
|
|
19
|
+
return filteredFonts;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=filter-fonts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["filterFonts","fonts","filters","category","search","filteredFonts","filter","font","name","toLowerCase","includes"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/filter-fonts.js"],"sourcesContent":["export default function filterFonts( fonts, filters ) {\n\tconst { category, search } = filters;\n\tlet filteredFonts = fonts || [];\n\n\tif ( category && category !== 'all' ) {\n\t\tfilteredFonts = filteredFonts.filter(\n\t\t\t( font ) => font.category === category\n\t\t);\n\t}\n\n\tif ( search ) {\n\t\tfilteredFonts = filteredFonts.filter( ( font ) =>\n\t\t\tfont.name.toLowerCase().includes( search.toLowerCase() )\n\t\t);\n\t}\n\n\treturn filteredFonts;\n}\n"],"mappings":";;;;;;AAAe,SAASA,WAAWA,CAAEC,KAAK,EAAEC,OAAO,EAAG;EACrD,MAAM;IAAEC,QAAQ;IAAEC;EAAO,CAAC,GAAGF,OAAO;EACpC,IAAIG,aAAa,GAAGJ,KAAK,IAAI,EAAE;EAE/B,IAAKE,QAAQ,IAAIA,QAAQ,KAAK,KAAK,EAAG;IACrCE,aAAa,GAAGA,aAAa,CAACC,MAAM,CACjCC,IAAI,IAAMA,IAAI,CAACJ,QAAQ,KAAKA,QAC/B,CAAC;EACF;EAEA,IAAKC,MAAM,EAAG;IACbC,aAAa,GAAGA,aAAa,CAACC,MAAM,CAAIC,IAAI,IAC3CA,IAAI,CAACC,IAAI,CAACC,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAEN,MAAM,CAACK,WAAW,CAAC,CAAE,CACxD,CAAC;EACF;EAEA,OAAOJ,aAAa;AACrB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getFontsOutline = getFontsOutline;
|
|
7
|
+
exports.isFontFontFaceInOutline = isFontFontFaceInOutline;
|
|
8
|
+
function getFontsOutline(fonts) {
|
|
9
|
+
return fonts.reduce((acc, font) => ({
|
|
10
|
+
...acc,
|
|
11
|
+
[font.slug]: (font?.fontFace || []).reduce((faces, face) => ({
|
|
12
|
+
...faces,
|
|
13
|
+
[`${face.fontStyle}-${face.fontWeight}`]: true
|
|
14
|
+
}), {})
|
|
15
|
+
}), {});
|
|
16
|
+
}
|
|
17
|
+
function isFontFontFaceInOutline(slug, face, outline) {
|
|
18
|
+
return outline[slug]?.[`${face.fontStyle}-${face.fontWeight}`] || false;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=fonts-outline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getFontsOutline","fonts","reduce","acc","font","slug","fontFace","faces","face","fontStyle","fontWeight","isFontFontFaceInOutline","outline"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/fonts-outline.js"],"sourcesContent":["export function getFontsOutline( fonts ) {\n\treturn fonts.reduce(\n\t\t( acc, font ) => ( {\n\t\t\t...acc,\n\t\t\t[ font.slug ]: ( font?.fontFace || [] ).reduce(\n\t\t\t\t( faces, face ) => ( {\n\t\t\t\t\t...faces,\n\t\t\t\t\t[ `${ face.fontStyle }-${ face.fontWeight }` ]: true,\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t} ),\n\t\t{}\n\t);\n}\n\nexport function isFontFontFaceInOutline( slug, face, outline ) {\n\treturn (\n\t\toutline[ slug ]?.[ `${ face.fontStyle }-${ face.fontWeight }` ] || false\n\t);\n}\n"],"mappings":";;;;;;;AAAO,SAASA,eAAeA,CAAEC,KAAK,EAAG;EACxC,OAAOA,KAAK,CAACC,MAAM,CAClB,CAAEC,GAAG,EAAEC,IAAI,MAAQ;IAClB,GAAGD,GAAG;IACN,CAAEC,IAAI,CAACC,IAAI,GAAI,CAAED,IAAI,EAAEE,QAAQ,IAAI,EAAE,EAAGJ,MAAM,CAC7C,CAAEK,KAAK,EAAEC,IAAI,MAAQ;MACpB,GAAGD,KAAK;MACR,CAAG,GAAGC,IAAI,CAACC,SAAW,IAAID,IAAI,CAACE,UAAY,EAAC,GAAI;IACjD,CAAC,CAAE,EACH,CAAC,CACF;EACD,CAAC,CAAE,EACH,CAAC,CACF,CAAC;AACF;AAEO,SAASC,uBAAuBA,CAAEN,IAAI,EAAEG,IAAI,EAAEI,OAAO,EAAG;EAC9D,OACCA,OAAO,CAAEP,IAAI,CAAE,GAAK,GAAGG,IAAI,CAACC,SAAW,IAAID,IAAI,CAACE,UAAY,EAAC,CAAE,IAAI,KAAK;AAE1E"}
|
package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = getIntersectingFontFaces;
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves intersecting font faces between two sets of fonts.
|
|
9
|
+
*
|
|
10
|
+
* For each font in the `incoming` list, the function checks for a corresponding match
|
|
11
|
+
* in the `existing` list based on the `slug` property. If a match is found and both
|
|
12
|
+
* have `fontFace` properties, it further narrows down to matching font faces based on
|
|
13
|
+
* the `fontWeight` and `fontStyle`. The result includes the properties of the matched
|
|
14
|
+
* existing font but only with intersecting font faces.
|
|
15
|
+
*
|
|
16
|
+
* @param {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} incoming - The list of fonts to compare.
|
|
17
|
+
* @param {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} existing - The reference list of fonts.
|
|
18
|
+
*
|
|
19
|
+
* @return {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} An array of fonts from the `existing` list with intersecting font faces.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const incomingFonts = [
|
|
23
|
+
* { slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] },
|
|
24
|
+
* { slug: 'times-new', fontFace: [{ fontWeight: '700', fontStyle: 'italic' }] }
|
|
25
|
+
* ];
|
|
26
|
+
*
|
|
27
|
+
* const existingFonts = [
|
|
28
|
+
* { slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }, { fontWeight: '700', fontStyle: 'italic' }] },
|
|
29
|
+
* { slug: 'helvetica', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] }
|
|
30
|
+
* ];
|
|
31
|
+
*
|
|
32
|
+
* getIntersectingFontFaces(incomingFonts, existingFonts);
|
|
33
|
+
* // Returns:
|
|
34
|
+
* // [{ slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] }]
|
|
35
|
+
*/
|
|
36
|
+
function getIntersectingFontFaces(incoming, existing) {
|
|
37
|
+
const matches = [];
|
|
38
|
+
for (const incomingFont of incoming) {
|
|
39
|
+
const existingFont = existing.find(f => f.slug === incomingFont.slug);
|
|
40
|
+
if (existingFont) {
|
|
41
|
+
if (incomingFont?.fontFace) {
|
|
42
|
+
const matchingFaces = incomingFont.fontFace.filter(face => {
|
|
43
|
+
return (existingFont?.fontFace || []).find(f => {
|
|
44
|
+
return f.fontWeight === face.fontWeight && f.fontStyle === face.fontStyle;
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
matches.push({
|
|
48
|
+
...existingFont,
|
|
49
|
+
fontFace: matchingFaces
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
matches.push(incomingFont);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return matches;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=get-intersecting-font-faces.js.map
|
package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getIntersectingFontFaces","incoming","existing","matches","incomingFont","existingFont","find","f","slug","fontFace","matchingFaces","filter","face","fontWeight","fontStyle","push"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js"],"sourcesContent":["/**\n * Retrieves intersecting font faces between two sets of fonts.\n *\n * For each font in the `incoming` list, the function checks for a corresponding match\n * in the `existing` list based on the `slug` property. If a match is found and both\n * have `fontFace` properties, it further narrows down to matching font faces based on\n * the `fontWeight` and `fontStyle`. The result includes the properties of the matched\n * existing font but only with intersecting font faces.\n *\n * @param {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} incoming - The list of fonts to compare.\n * @param {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} existing - The reference list of fonts.\n *\n * @return {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} An array of fonts from the `existing` list with intersecting font faces.\n *\n * @example\n * const incomingFonts = [\n * { slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] },\n * { slug: 'times-new', fontFace: [{ fontWeight: '700', fontStyle: 'italic' }] }\n * ];\n *\n * const existingFonts = [\n * { slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }, { fontWeight: '700', fontStyle: 'italic' }] },\n * { slug: 'helvetica', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] }\n * ];\n *\n * getIntersectingFontFaces(incomingFonts, existingFonts);\n * // Returns:\n * // [{ slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] }]\n */\nexport default function getIntersectingFontFaces( incoming, existing ) {\n\tconst matches = [];\n\n\tfor ( const incomingFont of incoming ) {\n\t\tconst existingFont = existing.find(\n\t\t\t( f ) => f.slug === incomingFont.slug\n\t\t);\n\n\t\tif ( existingFont ) {\n\t\t\tif ( incomingFont?.fontFace ) {\n\t\t\t\tconst matchingFaces = incomingFont.fontFace.filter(\n\t\t\t\t\t( face ) => {\n\t\t\t\t\t\treturn ( existingFont?.fontFace || [] ).find( ( f ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\tf.fontWeight === face.fontWeight &&\n\t\t\t\t\t\t\t\tf.fontStyle === face.fontStyle\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tmatches.push( { ...existingFont, fontFace: matchingFaces } );\n\t\t\t} else {\n\t\t\t\tmatches.push( incomingFont );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn matches;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,wBAAwBA,CAAEC,QAAQ,EAAEC,QAAQ,EAAG;EACtE,MAAMC,OAAO,GAAG,EAAE;EAElB,KAAM,MAAMC,YAAY,IAAIH,QAAQ,EAAG;IACtC,MAAMI,YAAY,GAAGH,QAAQ,CAACI,IAAI,CAC/BC,CAAC,IAAMA,CAAC,CAACC,IAAI,KAAKJ,YAAY,CAACI,IAClC,CAAC;IAED,IAAKH,YAAY,EAAG;MACnB,IAAKD,YAAY,EAAEK,QAAQ,EAAG;QAC7B,MAAMC,aAAa,GAAGN,YAAY,CAACK,QAAQ,CAACE,MAAM,CAC/CC,IAAI,IAAM;UACX,OAAO,CAAEP,YAAY,EAAEI,QAAQ,IAAI,EAAE,EAAGH,IAAI,CAAIC,CAAC,IAAM;YACtD,OACCA,CAAC,CAACM,UAAU,KAAKD,IAAI,CAACC,UAAU,IAChCN,CAAC,CAACO,SAAS,KAAKF,IAAI,CAACE,SAAS;UAEhC,CAAE,CAAC;QACJ,CACD,CAAC;QACDX,OAAO,CAACY,IAAI,CAAE;UAAE,GAAGV,YAAY;UAAEI,QAAQ,EAAEC;QAAc,CAAE,CAAC;MAC7D,CAAC,MAAM;QACNP,OAAO,CAACY,IAAI,CAAEX,YAAa,CAAC;MAC7B;IACD;EACD;EAEA,OAAOD,OAAO;AACf"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDisplaySrcFromFontFace = getDisplaySrcFromFontFace;
|
|
7
|
+
exports.getFontFaceVariantName = getFontFaceVariantName;
|
|
8
|
+
exports.isUrlEncoded = isUrlEncoded;
|
|
9
|
+
exports.loadFontFaceInBrowser = loadFontFaceInBrowser;
|
|
10
|
+
exports.makeFormDataFromFontFamilies = makeFormDataFromFontFamilies;
|
|
11
|
+
exports.mergeFontFaces = mergeFontFaces;
|
|
12
|
+
exports.mergeFontFamilies = mergeFontFamilies;
|
|
13
|
+
exports.setUIValuesNeeded = setUIValuesNeeded;
|
|
14
|
+
var _constants = require("./constants");
|
|
15
|
+
var _previewStyles = require("./preview-styles");
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function setUIValuesNeeded(font, extraValues = {}) {
|
|
21
|
+
if (!font.name && (font.fontFamily || font.slug)) {
|
|
22
|
+
font.name = font.fontFamily || font.slug;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
...font,
|
|
26
|
+
...extraValues
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function isUrlEncoded(url) {
|
|
30
|
+
if (typeof url !== 'string') {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return url !== decodeURIComponent(url);
|
|
34
|
+
}
|
|
35
|
+
function getFontFaceVariantName(face) {
|
|
36
|
+
const weightName = _constants.FONT_WEIGHTS[face.fontWeight] || face.fontWeight;
|
|
37
|
+
const styleName = face.fontStyle === 'normal' ? '' : _constants.FONT_STYLES[face.fontStyle] || face.fontStyle;
|
|
38
|
+
return `${weightName} ${styleName}`;
|
|
39
|
+
}
|
|
40
|
+
function mergeFontFaces(existing = [], incoming = []) {
|
|
41
|
+
const map = new Map();
|
|
42
|
+
for (const face of existing) {
|
|
43
|
+
map.set(`${face.fontWeight}${face.fontStyle}`, face);
|
|
44
|
+
}
|
|
45
|
+
for (const face of incoming) {
|
|
46
|
+
// This will overwrite if the src already exists, keeping it unique.
|
|
47
|
+
map.set(`${face.fontWeight}${face.fontStyle}`, face);
|
|
48
|
+
}
|
|
49
|
+
return Array.from(map.values());
|
|
50
|
+
}
|
|
51
|
+
function mergeFontFamilies(existing = [], incoming = []) {
|
|
52
|
+
const map = new Map();
|
|
53
|
+
// Add the existing array to the map.
|
|
54
|
+
for (const font of existing) {
|
|
55
|
+
map.set(font.slug, {
|
|
56
|
+
...font
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// Add the incoming array to the map, overwriting existing values excepting fontFace that need to be merged.
|
|
60
|
+
for (const font of incoming) {
|
|
61
|
+
if (map.has(font.slug)) {
|
|
62
|
+
const {
|
|
63
|
+
fontFace: incomingFontFaces,
|
|
64
|
+
...restIncoming
|
|
65
|
+
} = font;
|
|
66
|
+
const existingFont = map.get(font.slug);
|
|
67
|
+
// Merge the fontFaces existing with the incoming fontFaces.
|
|
68
|
+
const mergedFontFaces = mergeFontFaces(existingFont.fontFace, incomingFontFaces);
|
|
69
|
+
// Except for the fontFace key all the other keys are overwritten with the incoming values.
|
|
70
|
+
map.set(font.slug, {
|
|
71
|
+
...restIncoming,
|
|
72
|
+
fontFace: mergedFontFaces
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
map.set(font.slug, {
|
|
76
|
+
...font
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return Array.from(map.values());
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
* Loads the font face from a URL and adds it to the browser.
|
|
85
|
+
* It also adds it to the iframe document.
|
|
86
|
+
*/
|
|
87
|
+
async function loadFontFaceInBrowser(fontFace, source, addTo = 'all') {
|
|
88
|
+
let dataSource;
|
|
89
|
+
if (typeof source === 'string') {
|
|
90
|
+
dataSource = `url(${source})`;
|
|
91
|
+
// eslint-disable-next-line no-undef
|
|
92
|
+
} else if (source instanceof File) {
|
|
93
|
+
dataSource = await source.arrayBuffer();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// eslint-disable-next-line no-undef
|
|
97
|
+
const newFont = new FontFace((0, _previewStyles.formatFontFamily)(fontFace.fontFamily), dataSource, {
|
|
98
|
+
style: fontFace.fontStyle,
|
|
99
|
+
weight: fontFace.fontWeight
|
|
100
|
+
});
|
|
101
|
+
const loadedFace = await newFont.load();
|
|
102
|
+
if (addTo === 'document' || addTo === 'all') {
|
|
103
|
+
document.fonts.add(loadedFace);
|
|
104
|
+
}
|
|
105
|
+
if (addTo === 'iframe' || addTo === 'all') {
|
|
106
|
+
const iframeDocument = document.querySelector('iframe[name="editor-canvas"]').contentDocument;
|
|
107
|
+
iframeDocument.fonts.add(loadedFace);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function getDisplaySrcFromFontFace(input, urlPrefix) {
|
|
111
|
+
let src;
|
|
112
|
+
if (Array.isArray(input)) {
|
|
113
|
+
src = input[0];
|
|
114
|
+
} else {
|
|
115
|
+
src = input;
|
|
116
|
+
}
|
|
117
|
+
// If it is a theme font, we need to make the url absolute
|
|
118
|
+
if (src.startsWith('file:.') && urlPrefix) {
|
|
119
|
+
src = src.replace('file:.', urlPrefix);
|
|
120
|
+
}
|
|
121
|
+
if (!isUrlEncoded(src)) {
|
|
122
|
+
src = encodeURI(src);
|
|
123
|
+
}
|
|
124
|
+
return src;
|
|
125
|
+
}
|
|
126
|
+
function makeFormDataFromFontFamilies(fontFamilies) {
|
|
127
|
+
const formData = new FormData();
|
|
128
|
+
const newFontFamilies = fontFamilies.map((family, familyIndex) => {
|
|
129
|
+
if (family?.fontFace) {
|
|
130
|
+
family.fontFace = family.fontFace.map((face, faceIndex) => {
|
|
131
|
+
if (face.file) {
|
|
132
|
+
// Slugified file name because the it might contain spaces or characters treated differently on the server.
|
|
133
|
+
const fileId = `file-${familyIndex}-${faceIndex}`;
|
|
134
|
+
// Add the files to the formData
|
|
135
|
+
formData.append(fileId, face.file, face.file.name);
|
|
136
|
+
// remove the file object from the face object the file is referenced by the uploadedFile key
|
|
137
|
+
const {
|
|
138
|
+
file,
|
|
139
|
+
...faceWithoutFileProperty
|
|
140
|
+
} = face;
|
|
141
|
+
const newFace = {
|
|
142
|
+
...faceWithoutFileProperty,
|
|
143
|
+
uploadedFile: fileId
|
|
144
|
+
};
|
|
145
|
+
return newFace;
|
|
146
|
+
}
|
|
147
|
+
return face;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return family;
|
|
151
|
+
});
|
|
152
|
+
formData.append('fontFamilies', JSON.stringify(newFontFamilies));
|
|
153
|
+
return formData;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_constants","require","_previewStyles","setUIValuesNeeded","font","extraValues","name","fontFamily","slug","isUrlEncoded","url","decodeURIComponent","getFontFaceVariantName","face","weightName","FONT_WEIGHTS","fontWeight","styleName","fontStyle","FONT_STYLES","mergeFontFaces","existing","incoming","map","Map","set","Array","from","values","mergeFontFamilies","has","fontFace","incomingFontFaces","restIncoming","existingFont","get","mergedFontFaces","loadFontFaceInBrowser","source","addTo","dataSource","File","arrayBuffer","newFont","FontFace","formatFontFamily","style","weight","loadedFace","load","document","fonts","add","iframeDocument","querySelector","contentDocument","getDisplaySrcFromFontFace","input","urlPrefix","src","isArray","startsWith","replace","encodeURI","makeFormDataFromFontFamilies","fontFamilies","formData","FormData","newFontFamilies","family","familyIndex","faceIndex","file","fileId","append","faceWithoutFileProperty","newFace","uploadedFile","JSON","stringify"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { FONT_WEIGHTS, FONT_STYLES } from './constants';\nimport { formatFontFamily } from './preview-styles';\n\nexport function setUIValuesNeeded( font, extraValues = {} ) {\n\tif ( ! font.name && ( font.fontFamily || font.slug ) ) {\n\t\tfont.name = font.fontFamily || font.slug;\n\t}\n\treturn {\n\t\t...font,\n\t\t...extraValues,\n\t};\n}\n\nexport function isUrlEncoded( url ) {\n\tif ( typeof url !== 'string' ) {\n\t\treturn false;\n\t}\n\treturn url !== decodeURIComponent( url );\n}\n\nexport function getFontFaceVariantName( face ) {\n\tconst weightName = FONT_WEIGHTS[ face.fontWeight ] || face.fontWeight;\n\tconst styleName =\n\t\tface.fontStyle === 'normal'\n\t\t\t? ''\n\t\t\t: FONT_STYLES[ face.fontStyle ] || face.fontStyle;\n\treturn `${ weightName } ${ styleName }`;\n}\n\nexport function mergeFontFaces( existing = [], incoming = [] ) {\n\tconst map = new Map();\n\tfor ( const face of existing ) {\n\t\tmap.set( `${ face.fontWeight }${ face.fontStyle }`, face );\n\t}\n\tfor ( const face of incoming ) {\n\t\t// This will overwrite if the src already exists, keeping it unique.\n\t\tmap.set( `${ face.fontWeight }${ face.fontStyle }`, face );\n\t}\n\treturn Array.from( map.values() );\n}\n\nexport function mergeFontFamilies( existing = [], incoming = [] ) {\n\tconst map = new Map();\n\t// Add the existing array to the map.\n\tfor ( const font of existing ) {\n\t\tmap.set( font.slug, { ...font } );\n\t}\n\t// Add the incoming array to the map, overwriting existing values excepting fontFace that need to be merged.\n\tfor ( const font of incoming ) {\n\t\tif ( map.has( font.slug ) ) {\n\t\t\tconst { fontFace: incomingFontFaces, ...restIncoming } = font;\n\t\t\tconst existingFont = map.get( font.slug );\n\t\t\t// Merge the fontFaces existing with the incoming fontFaces.\n\t\t\tconst mergedFontFaces = mergeFontFaces(\n\t\t\t\texistingFont.fontFace,\n\t\t\t\tincomingFontFaces\n\t\t\t);\n\t\t\t// Except for the fontFace key all the other keys are overwritten with the incoming values.\n\t\t\tmap.set( font.slug, {\n\t\t\t\t...restIncoming,\n\t\t\t\tfontFace: mergedFontFaces,\n\t\t\t} );\n\t\t} else {\n\t\t\tmap.set( font.slug, { ...font } );\n\t\t}\n\t}\n\treturn Array.from( map.values() );\n}\n\n/*\n * Loads the font face from a URL and adds it to the browser.\n * It also adds it to the iframe document.\n */\nexport async function loadFontFaceInBrowser( fontFace, source, addTo = 'all' ) {\n\tlet dataSource;\n\n\tif ( typeof source === 'string' ) {\n\t\tdataSource = `url(${ source })`;\n\t\t// eslint-disable-next-line no-undef\n\t} else if ( source instanceof File ) {\n\t\tdataSource = await source.arrayBuffer();\n\t}\n\n\t// eslint-disable-next-line no-undef\n\tconst newFont = new FontFace(\n\t\tformatFontFamily( fontFace.fontFamily ),\n\t\tdataSource,\n\t\t{\n\t\t\tstyle: fontFace.fontStyle,\n\t\t\tweight: fontFace.fontWeight,\n\t\t}\n\t);\n\n\tconst loadedFace = await newFont.load();\n\n\tif ( addTo === 'document' || addTo === 'all' ) {\n\t\tdocument.fonts.add( loadedFace );\n\t}\n\n\tif ( addTo === 'iframe' || addTo === 'all' ) {\n\t\tconst iframeDocument = document.querySelector(\n\t\t\t'iframe[name=\"editor-canvas\"]'\n\t\t).contentDocument;\n\t\tiframeDocument.fonts.add( loadedFace );\n\t}\n}\n\nexport function getDisplaySrcFromFontFace( input, urlPrefix ) {\n\tlet src;\n\tif ( Array.isArray( input ) ) {\n\t\tsrc = input[ 0 ];\n\t} else {\n\t\tsrc = input;\n\t}\n\t// If it is a theme font, we need to make the url absolute\n\tif ( src.startsWith( 'file:.' ) && urlPrefix ) {\n\t\tsrc = src.replace( 'file:.', urlPrefix );\n\t}\n\tif ( ! isUrlEncoded( src ) ) {\n\t\tsrc = encodeURI( src );\n\t}\n\treturn src;\n}\n\nexport function makeFormDataFromFontFamilies( fontFamilies ) {\n\tconst formData = new FormData();\n\tconst newFontFamilies = fontFamilies.map( ( family, familyIndex ) => {\n\t\tif ( family?.fontFace ) {\n\t\t\tfamily.fontFace = family.fontFace.map( ( face, faceIndex ) => {\n\t\t\t\tif ( face.file ) {\n\t\t\t\t\t// Slugified file name because the it might contain spaces or characters treated differently on the server.\n\t\t\t\t\tconst fileId = `file-${ familyIndex }-${ faceIndex }`;\n\t\t\t\t\t// Add the files to the formData\n\t\t\t\t\tformData.append( fileId, face.file, face.file.name );\n\t\t\t\t\t// remove the file object from the face object the file is referenced by the uploadedFile key\n\t\t\t\t\tconst { file, ...faceWithoutFileProperty } = face;\n\t\t\t\t\tconst newFace = {\n\t\t\t\t\t\t...faceWithoutFileProperty,\n\t\t\t\t\t\tuploadedFile: fileId,\n\t\t\t\t\t};\n\t\t\t\t\treturn newFace;\n\t\t\t\t}\n\t\t\t\treturn face;\n\t\t\t} );\n\t\t}\n\t\treturn family;\n\t} );\n\tformData.append( 'fontFamilies', JSON.stringify( newFontFamilies ) );\n\treturn formData;\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|
|
6
|
+
exports.default = makeFamiliesFromFaces;
|
|
7
|
+
function makeFamiliesFromFaces(fontFaces) {
|
|
8
|
+
const fontFamiliesObject = fontFaces.reduce((acc, item) => {
|
|
9
|
+
if (!acc[item.fontFamily]) {
|
|
10
|
+
acc[item.fontFamily] = {
|
|
11
|
+
name: item.fontFamily,
|
|
12
|
+
fontFamily: item.fontFamily,
|
|
13
|
+
slug: item.fontFamily.replace(/\s+/g, '-').toLowerCase(),
|
|
14
|
+
fontFace: []
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
acc[item.fontFamily].fontFace.push(item);
|
|
18
|
+
return acc;
|
|
19
|
+
}, {});
|
|
20
|
+
return Object.values(fontFamiliesObject);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=make-families-from-faces.js.map
|
package/build/components/global-styles/font-library-modal/utils/make-families-from-faces.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["makeFamiliesFromFaces","fontFaces","fontFamiliesObject","reduce","acc","item","fontFamily","name","slug","replace","toLowerCase","fontFace","push","Object","values"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/make-families-from-faces.js"],"sourcesContent":["export default function makeFamiliesFromFaces( fontFaces ) {\n\tconst fontFamiliesObject = fontFaces.reduce( ( acc, item ) => {\n\t\tif ( ! acc[ item.fontFamily ] ) {\n\t\t\tacc[ item.fontFamily ] = {\n\t\t\t\tname: item.fontFamily,\n\t\t\t\tfontFamily: item.fontFamily,\n\t\t\t\tslug: item.fontFamily.replace( /\\s+/g, '-' ).toLowerCase(),\n\t\t\t\tfontFace: [],\n\t\t\t};\n\t\t}\n\t\tacc[ item.fontFamily ].fontFace.push( item );\n\t\treturn acc;\n\t}, {} );\n\treturn Object.values( fontFamiliesObject );\n}\n"],"mappings":";;;;;;AAAe,SAASA,qBAAqBA,CAAEC,SAAS,EAAG;EAC1D,MAAMC,kBAAkB,GAAGD,SAAS,CAACE,MAAM,CAAE,CAAEC,GAAG,EAAEC,IAAI,KAAM;IAC7D,IAAK,CAAED,GAAG,CAAEC,IAAI,CAACC,UAAU,CAAE,EAAG;MAC/BF,GAAG,CAAEC,IAAI,CAACC,UAAU,CAAE,GAAG;QACxBC,IAAI,EAAEF,IAAI,CAACC,UAAU;QACrBA,UAAU,EAAED,IAAI,CAACC,UAAU;QAC3BE,IAAI,EAAEH,IAAI,CAACC,UAAU,CAACG,OAAO,CAAE,MAAM,EAAE,GAAI,CAAC,CAACC,WAAW,CAAC,CAAC;QAC1DC,QAAQ,EAAE;MACX,CAAC;IACF;IACAP,GAAG,CAAEC,IAAI,CAACC,UAAU,CAAE,CAACK,QAAQ,CAACC,IAAI,CAAEP,IAAK,CAAC;IAC5C,OAAOD,GAAG;EACX,CAAC,EAAE,CAAC,CAAE,CAAC;EACP,OAAOS,MAAM,CAACC,MAAM,CAAEZ,kBAAmB,CAAC;AAC3C"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatFontFamily = formatFontFamily;
|
|
7
|
+
exports.getFacePreviewStyle = getFacePreviewStyle;
|
|
8
|
+
exports.getFamilyPreviewStyle = getFamilyPreviewStyle;
|
|
9
|
+
function findNearest(input, numbers) {
|
|
10
|
+
// If the numbers array is empty, return null
|
|
11
|
+
if (numbers.length === 0) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
// Sort the array based on the absolute difference with the input
|
|
15
|
+
numbers.sort((a, b) => Math.abs(input - a) - Math.abs(input - b));
|
|
16
|
+
// Return the first element (which will be the nearest) from the sorted array
|
|
17
|
+
return numbers[0];
|
|
18
|
+
}
|
|
19
|
+
function extractFontWeights(fontFaces) {
|
|
20
|
+
const result = [];
|
|
21
|
+
fontFaces.forEach(face => {
|
|
22
|
+
const weights = String(face.fontWeight).split(' ');
|
|
23
|
+
if (weights.length === 2) {
|
|
24
|
+
const start = parseInt(weights[0]);
|
|
25
|
+
const end = parseInt(weights[1]);
|
|
26
|
+
for (let i = start; i <= end; i += 100) {
|
|
27
|
+
result.push(i);
|
|
28
|
+
}
|
|
29
|
+
} else if (weights.length === 1) {
|
|
30
|
+
result.push(parseInt(weights[0]));
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
function formatFontFamily(input) {
|
|
36
|
+
return input.split(',').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
|
+
}).join(', ');
|
|
44
|
+
}
|
|
45
|
+
function getFamilyPreviewStyle(family) {
|
|
46
|
+
const style = {
|
|
47
|
+
fontFamily: formatFontFamily(family.fontFamily)
|
|
48
|
+
};
|
|
49
|
+
if (!Array.isArray(family.fontFace)) {
|
|
50
|
+
style.fontWeight = '400';
|
|
51
|
+
style.fontStyle = 'normal';
|
|
52
|
+
return style;
|
|
53
|
+
}
|
|
54
|
+
if (family.fontFace) {
|
|
55
|
+
//get all the font faces with normal style
|
|
56
|
+
const normalFaces = family.fontFace.filter(face => face.fontStyle.toLowerCase() === 'normal');
|
|
57
|
+
if (normalFaces.length > 0) {
|
|
58
|
+
style.fontStyle = 'normal';
|
|
59
|
+
const normalWeights = extractFontWeights(normalFaces);
|
|
60
|
+
const nearestWeight = findNearest(400, normalWeights);
|
|
61
|
+
style.fontWeight = String(nearestWeight) || '400';
|
|
62
|
+
} else {
|
|
63
|
+
style.fontStyle = family.fontFace.length && family.fontFace[0].fontStyle || 'normal';
|
|
64
|
+
style.fontWeight = family.fontFace.length && String(family.fontFace[0].fontWeight) || '400';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return style;
|
|
68
|
+
}
|
|
69
|
+
function getFacePreviewStyle(face) {
|
|
70
|
+
return {
|
|
71
|
+
fontFamily: formatFontFamily(face.fontFamily),
|
|
72
|
+
fontStyle: face.fontStyle || 'normal',
|
|
73
|
+
fontWeight: face.fontWeight || '400'
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=preview-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["findNearest","input","numbers","length","sort","a","b","Math","abs","extractFontWeights","fontFaces","result","forEach","face","weights","String","fontWeight","split","start","parseInt","end","i","push","formatFontFamily","map","font","trim","startsWith","indexOf","join","getFamilyPreviewStyle","family","style","fontFamily","Array","isArray","fontFace","fontStyle","normalFaces","filter","toLowerCase","normalWeights","nearestWeight","getFacePreviewStyle"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/preview-styles.js"],"sourcesContent":["function findNearest( input, numbers ) {\n\t// If the numbers array is empty, return null\n\tif ( numbers.length === 0 ) {\n\t\treturn null;\n\t}\n\t// Sort the array based on the absolute difference with the input\n\tnumbers.sort( ( a, b ) => Math.abs( input - a ) - Math.abs( input - b ) );\n\t// Return the first element (which will be the nearest) from the sorted array\n\treturn numbers[ 0 ];\n}\n\nfunction extractFontWeights( fontFaces ) {\n\tconst result = [];\n\n\tfontFaces.forEach( ( face ) => {\n\t\tconst weights = String( face.fontWeight ).split( ' ' );\n\n\t\tif ( weights.length === 2 ) {\n\t\t\tconst start = parseInt( weights[ 0 ] );\n\t\t\tconst end = parseInt( weights[ 1 ] );\n\n\t\t\tfor ( let i = start; i <= end; i += 100 ) {\n\t\t\t\tresult.push( i );\n\t\t\t}\n\t\t} else if ( weights.length === 1 ) {\n\t\t\tresult.push( parseInt( weights[ 0 ] ) );\n\t\t}\n\t} );\n\n\treturn result;\n}\n\nexport function formatFontFamily( input ) {\n\treturn input\n\t\t.split( ',' )\n\t\t.map( ( font ) => {\n\t\t\tfont = font.trim(); // Remove any leading or trailing white spaces\n\t\t\t// If the font doesn't have single quotes and contains a space, then add single quotes around it\n\t\t\tif ( ! font.startsWith( \"'\" ) && font.indexOf( ' ' ) !== -1 ) {\n\t\t\t\treturn `'${ font }'`;\n\t\t\t}\n\t\t\treturn font; // Return font as is if no transformation is needed\n\t\t} )\n\t\t.join( ', ' );\n}\n\nexport function getFamilyPreviewStyle( family ) {\n\tconst style = { fontFamily: formatFontFamily( family.fontFamily ) };\n\n\tif ( ! Array.isArray( family.fontFace ) ) {\n\t\tstyle.fontWeight = '400';\n\t\tstyle.fontStyle = 'normal';\n\t\treturn style;\n\t}\n\n\tif ( family.fontFace ) {\n\t\t//get all the font faces with normal style\n\t\tconst normalFaces = family.fontFace.filter(\n\t\t\t( face ) => face.fontStyle.toLowerCase() === 'normal'\n\t\t);\n\t\tif ( normalFaces.length > 0 ) {\n\t\t\tstyle.fontStyle = 'normal';\n\t\t\tconst normalWeights = extractFontWeights( normalFaces );\n\t\t\tconst nearestWeight = findNearest( 400, normalWeights );\n\t\t\tstyle.fontWeight = String( nearestWeight ) || '400';\n\t\t} else {\n\t\t\tstyle.fontStyle =\n\t\t\t\t( family.fontFace.length && family.fontFace[ 0 ].fontStyle ) ||\n\t\t\t\t'normal';\n\t\t\tstyle.fontWeight =\n\t\t\t\t( family.fontFace.length &&\n\t\t\t\t\tString( family.fontFace[ 0 ].fontWeight ) ) ||\n\t\t\t\t'400';\n\t\t}\n\t}\n\n\treturn style;\n}\n\nexport function getFacePreviewStyle( face ) {\n\treturn {\n\t\tfontFamily: formatFontFamily( face.fontFamily ),\n\t\tfontStyle: face.fontStyle || 'normal',\n\t\tfontWeight: face.fontWeight || '400',\n\t};\n}\n"],"mappings":";;;;;;;;AAAA,SAASA,WAAWA,CAAEC,KAAK,EAAEC,OAAO,EAAG;EACtC;EACA,IAAKA,OAAO,CAACC,MAAM,KAAK,CAAC,EAAG;IAC3B,OAAO,IAAI;EACZ;EACA;EACAD,OAAO,CAAC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,CAAC,IAC1C,KAAK;IACP;EACD;EAEA,OAAOgB,KAAK;AACb;AAEO,SAASW,mBAAmBA,CAAE9B,IAAI,EAAG;EAC3C,OAAO;IACNoB,UAAU,EAAEV,gBAAgB,CAAEV,IAAI,CAACoB,UAAW,CAAC;IAC/CI,SAAS,EAAExB,IAAI,CAACwB,SAAS,IAAI,QAAQ;IACrCrB,UAAU,EAAEH,IAAI,CAACG,UAAU,IAAI;EAChC,CAAC;AACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.sortFontFaces = sortFontFaces;
|
|
7
|
+
function getNumericFontWeight(value) {
|
|
8
|
+
switch (value) {
|
|
9
|
+
case 'normal':
|
|
10
|
+
return 400;
|
|
11
|
+
case 'bold':
|
|
12
|
+
return 700;
|
|
13
|
+
case 'bolder':
|
|
14
|
+
return 500;
|
|
15
|
+
case 'lighter':
|
|
16
|
+
return 300;
|
|
17
|
+
default:
|
|
18
|
+
return parseInt(value, 10);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function sortFontFaces(faces) {
|
|
22
|
+
return faces.sort((a, b) => {
|
|
23
|
+
// Ensure 'normal' fontStyle is always first
|
|
24
|
+
if (a.fontStyle === 'normal' && b.fontStyle !== 'normal') return -1;
|
|
25
|
+
if (b.fontStyle === 'normal' && a.fontStyle !== 'normal') return 1;
|
|
26
|
+
|
|
27
|
+
// If both fontStyles are the same, sort by fontWeight
|
|
28
|
+
if (a.fontStyle === b.fontStyle) {
|
|
29
|
+
return getNumericFontWeight(a.fontWeight) - getNumericFontWeight(b.fontWeight);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Sort other fontStyles alphabetically
|
|
33
|
+
return a.fontStyle.localeCompare(b.fontStyle);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=sort-font-faces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getNumericFontWeight","value","parseInt","sortFontFaces","faces","sort","a","b","fontStyle","fontWeight","localeCompare"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/sort-font-faces.js"],"sourcesContent":["function getNumericFontWeight( value ) {\n\tswitch ( value ) {\n\t\tcase 'normal':\n\t\t\treturn 400;\n\t\tcase 'bold':\n\t\t\treturn 700;\n\t\tcase 'bolder':\n\t\t\treturn 500;\n\t\tcase 'lighter':\n\t\t\treturn 300;\n\t\tdefault:\n\t\t\treturn parseInt( value, 10 );\n\t}\n}\n\nexport function sortFontFaces( faces ) {\n\treturn faces.sort( ( a, b ) => {\n\t\t// Ensure 'normal' fontStyle is always first\n\t\tif ( a.fontStyle === 'normal' && b.fontStyle !== 'normal' ) return -1;\n\t\tif ( b.fontStyle === 'normal' && a.fontStyle !== 'normal' ) return 1;\n\n\t\t// If both fontStyles are the same, sort by fontWeight\n\t\tif ( a.fontStyle === b.fontStyle ) {\n\t\t\treturn (\n\t\t\t\tgetNumericFontWeight( a.fontWeight ) -\n\t\t\t\tgetNumericFontWeight( b.fontWeight )\n\t\t\t);\n\t\t}\n\n\t\t// Sort other fontStyles alphabetically\n\t\treturn a.fontStyle.localeCompare( b.fontStyle );\n\t} );\n}\n"],"mappings":";;;;;;AAAA,SAASA,oBAAoBA,CAAEC,KAAK,EAAG;EACtC,QAASA,KAAK;IACb,KAAK,QAAQ;MACZ,OAAO,GAAG;IACX,KAAK,MAAM;MACV,OAAO,GAAG;IACX,KAAK,QAAQ;MACZ,OAAO,GAAG;IACX,KAAK,SAAS;MACb,OAAO,GAAG;IACX;MACC,OAAOC,QAAQ,CAAED,KAAK,EAAE,EAAG,CAAC;EAC9B;AACD;AAEO,SAASE,aAAaA,CAAEC,KAAK,EAAG;EACtC,OAAOA,KAAK,CAACC,IAAI,CAAE,CAAEC,CAAC,EAAEC,CAAC,KAAM;IAC9B;IACA,IAAKD,CAAC,CAACE,SAAS,KAAK,QAAQ,IAAID,CAAC,CAACC,SAAS,KAAK,QAAQ,EAAG,OAAO,CAAC,CAAC;IACrE,IAAKD,CAAC,CAACC,SAAS,KAAK,QAAQ,IAAIF,CAAC,CAACE,SAAS,KAAK,QAAQ,EAAG,OAAO,CAAC;;IAEpE;IACA,IAAKF,CAAC,CAACE,SAAS,KAAKD,CAAC,CAACC,SAAS,EAAG;MAClC,OACCR,oBAAoB,CAAEM,CAAC,CAACG,UAAW,CAAC,GACpCT,oBAAoB,CAAEO,CAAC,CAACE,UAAW,CAAC;IAEtC;;IAEA;IACA,OAAOH,CAAC,CAACE,SAAS,CAACE,aAAa,CAAEH,CAAC,CAACC,SAAU,CAAC;EAChD,CAAE,CAAC;AACJ"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toggleFont = toggleFont;
|
|
7
|
+
/**
|
|
8
|
+
* Toggles the activation of a given font or font variant within a list of custom fonts.
|
|
9
|
+
*
|
|
10
|
+
* - If only the font is provided (without face), the entire font family's activation is toggled.
|
|
11
|
+
* - If both font and face are provided, the activation of the specific font variant is toggled.
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} font - The font to be toggled.
|
|
14
|
+
* @param {string} font.slug - The unique identifier for the font.
|
|
15
|
+
* @param {Array} [font.fontFace] - The list of font variants (faces) associated with the font.
|
|
16
|
+
*
|
|
17
|
+
* @param {Object} [face] - The specific font variant to be toggled.
|
|
18
|
+
* @param {string} face.fontWeight - The weight of the font variant.
|
|
19
|
+
* @param {string} face.fontStyle - The style of the font variant.
|
|
20
|
+
*
|
|
21
|
+
* @param {Array} initialfonts - The initial list of custom fonts.
|
|
22
|
+
*
|
|
23
|
+
* @return {Array} - The updated list of custom fonts with the font/font variant toggled.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const customFonts = [
|
|
27
|
+
* { slug: 'roboto', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] }
|
|
28
|
+
* ];
|
|
29
|
+
*
|
|
30
|
+
* toggleFont({ slug: 'roboto' }, null, customFonts);
|
|
31
|
+
* // This will remove 'roboto' from customFonts
|
|
32
|
+
*
|
|
33
|
+
* toggleFont({ slug: 'roboto' }, { fontWeight: '400', fontStyle: 'normal' }, customFonts);
|
|
34
|
+
* // This will remove the specified face from 'roboto' in customFonts
|
|
35
|
+
*
|
|
36
|
+
* toggleFont({ slug: 'roboto' }, { fontWeight: '500', fontStyle: 'normal' }, customFonts);
|
|
37
|
+
* // This will add the specified face to 'roboto' in customFonts
|
|
38
|
+
*/
|
|
39
|
+
function toggleFont(font, face, initialfonts) {
|
|
40
|
+
// Helper to check if a font is activated based on its slug
|
|
41
|
+
const isFontActivated = f => f.slug === font.slug;
|
|
42
|
+
|
|
43
|
+
// Helper to get the activated font from a list of fonts
|
|
44
|
+
const getActivatedFont = fonts => fonts.find(isFontActivated);
|
|
45
|
+
|
|
46
|
+
// Toggle the activation status of an entire font family
|
|
47
|
+
const toggleEntireFontFamily = activatedFont => {
|
|
48
|
+
if (!activatedFont) {
|
|
49
|
+
// If the font is not active, activate the entire font family
|
|
50
|
+
return [...initialfonts, font];
|
|
51
|
+
}
|
|
52
|
+
// If the font is already active, deactivate the entire font family
|
|
53
|
+
return initialfonts.filter(f => !isFontActivated(f));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Toggle the activation status of a specific font variant
|
|
57
|
+
const toggleFontVariant = activatedFont => {
|
|
58
|
+
const isFaceActivated = f => f.fontWeight === face.fontWeight && f.fontStyle === face.fontStyle;
|
|
59
|
+
if (!activatedFont) {
|
|
60
|
+
// If the font family is not active, activate the font family with the font variant
|
|
61
|
+
return [...initialfonts, {
|
|
62
|
+
...font,
|
|
63
|
+
fontFace: [face]
|
|
64
|
+
}];
|
|
65
|
+
}
|
|
66
|
+
let newFontFaces = activatedFont.fontFace || [];
|
|
67
|
+
if (newFontFaces.find(isFaceActivated)) {
|
|
68
|
+
// If the font variant is active, deactivate it
|
|
69
|
+
newFontFaces = newFontFaces.filter(f => !isFaceActivated(f));
|
|
70
|
+
} else {
|
|
71
|
+
// If the font variant is not active, activate it
|
|
72
|
+
newFontFaces = [...newFontFaces, face];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// If there are no more font faces, deactivate the font family
|
|
76
|
+
if (newFontFaces.length === 0) {
|
|
77
|
+
return initialfonts.filter(f => !isFontActivated(f));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Return updated fonts list with toggled font variant
|
|
81
|
+
return initialfonts.map(f => isFontActivated(f) ? {
|
|
82
|
+
...f,
|
|
83
|
+
fontFace: newFontFaces
|
|
84
|
+
} : f);
|
|
85
|
+
};
|
|
86
|
+
const activatedFont = getActivatedFont(initialfonts);
|
|
87
|
+
if (!face) {
|
|
88
|
+
return toggleEntireFontFamily(activatedFont);
|
|
89
|
+
}
|
|
90
|
+
return toggleFontVariant(activatedFont);
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=toggleFont.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["toggleFont","font","face","initialfonts","isFontActivated","f","slug","getActivatedFont","fonts","find","toggleEntireFontFamily","activatedFont","filter","toggleFontVariant","isFaceActivated","fontWeight","fontStyle","fontFace","newFontFaces","length","map"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/toggleFont.js"],"sourcesContent":["/**\n * Toggles the activation of a given font or font variant within a list of custom fonts.\n *\n * - If only the font is provided (without face), the entire font family's activation is toggled.\n * - If both font and face are provided, the activation of the specific font variant is toggled.\n *\n * @param {Object} font - The font to be toggled.\n * @param {string} font.slug - The unique identifier for the font.\n * @param {Array} [font.fontFace] - The list of font variants (faces) associated with the font.\n *\n * @param {Object} [face] - The specific font variant to be toggled.\n * @param {string} face.fontWeight - The weight of the font variant.\n * @param {string} face.fontStyle - The style of the font variant.\n *\n * @param {Array} initialfonts - The initial list of custom fonts.\n *\n * @return {Array} - The updated list of custom fonts with the font/font variant toggled.\n *\n * @example\n * const customFonts = [\n * { slug: 'roboto', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] }\n * ];\n *\n * toggleFont({ slug: 'roboto' }, null, customFonts);\n * // This will remove 'roboto' from customFonts\n *\n * toggleFont({ slug: 'roboto' }, { fontWeight: '400', fontStyle: 'normal' }, customFonts);\n * // This will remove the specified face from 'roboto' in customFonts\n *\n * toggleFont({ slug: 'roboto' }, { fontWeight: '500', fontStyle: 'normal' }, customFonts);\n * // This will add the specified face to 'roboto' in customFonts\n */\nexport function toggleFont( font, face, initialfonts ) {\n\t// Helper to check if a font is activated based on its slug\n\tconst isFontActivated = ( f ) => f.slug === font.slug;\n\n\t// Helper to get the activated font from a list of fonts\n\tconst getActivatedFont = ( fonts ) => fonts.find( isFontActivated );\n\n\t// Toggle the activation status of an entire font family\n\tconst toggleEntireFontFamily = ( activatedFont ) => {\n\t\tif ( ! activatedFont ) {\n\t\t\t// If the font is not active, activate the entire font family\n\t\t\treturn [ ...initialfonts, font ];\n\t\t}\n\t\t// If the font is already active, deactivate the entire font family\n\t\treturn initialfonts.filter( ( f ) => ! isFontActivated( f ) );\n\t};\n\n\t// Toggle the activation status of a specific font variant\n\tconst toggleFontVariant = ( activatedFont ) => {\n\t\tconst isFaceActivated = ( f ) =>\n\t\t\tf.fontWeight === face.fontWeight && f.fontStyle === face.fontStyle;\n\n\t\tif ( ! activatedFont ) {\n\t\t\t// If the font family is not active, activate the font family with the font variant\n\t\t\treturn [ ...initialfonts, { ...font, fontFace: [ face ] } ];\n\t\t}\n\n\t\tlet newFontFaces = activatedFont.fontFace || [];\n\n\t\tif ( newFontFaces.find( isFaceActivated ) ) {\n\t\t\t// If the font variant is active, deactivate it\n\t\t\tnewFontFaces = newFontFaces.filter(\n\t\t\t\t( f ) => ! isFaceActivated( f )\n\t\t\t);\n\t\t} else {\n\t\t\t// If the font variant is not active, activate it\n\t\t\tnewFontFaces = [ ...newFontFaces, face ];\n\t\t}\n\n\t\t// If there are no more font faces, deactivate the font family\n\t\tif ( newFontFaces.length === 0 ) {\n\t\t\treturn initialfonts.filter( ( f ) => ! isFontActivated( f ) );\n\t\t}\n\n\t\t// Return updated fonts list with toggled font variant\n\t\treturn initialfonts.map( ( f ) =>\n\t\t\tisFontActivated( f ) ? { ...f, fontFace: newFontFaces } : f\n\t\t);\n\t};\n\n\tconst activatedFont = getActivatedFont( initialfonts );\n\n\tif ( ! face ) {\n\t\treturn toggleEntireFontFamily( activatedFont );\n\t}\n\n\treturn toggleFontVariant( activatedFont );\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,UAAUA,CAAEC,IAAI,EAAEC,IAAI,EAAEC,YAAY,EAAG;EACtD;EACA,MAAMC,eAAe,GAAKC,CAAC,IAAMA,CAAC,CAACC,IAAI,KAAKL,IAAI,CAACK,IAAI;;EAErD;EACA,MAAMC,gBAAgB,GAAKC,KAAK,IAAMA,KAAK,CAACC,IAAI,CAAEL,eAAgB,CAAC;;EAEnE;EACA,MAAMM,sBAAsB,GAAKC,aAAa,IAAM;IACnD,IAAK,CAAEA,aAAa,EAAG;MACtB;MACA,OAAO,CAAE,GAAGR,YAAY,EAAEF,IAAI,CAAE;IACjC;IACA;IACA,OAAOE,YAAY,CAACS,MAAM,CAAIP,CAAC,IAAM,CAAED,eAAe,CAAEC,CAAE,CAAE,CAAC;EAC9D,CAAC;;EAED;EACA,MAAMQ,iBAAiB,GAAKF,aAAa,IAAM;IAC9C,MAAMG,eAAe,GAAKT,CAAC,IAC1BA,CAAC,CAACU,UAAU,KAAKb,IAAI,CAACa,UAAU,IAAIV,CAAC,CAACW,SAAS,KAAKd,IAAI,CAACc,SAAS;IAEnE,IAAK,CAAEL,aAAa,EAAG;MACtB;MACA,OAAO,CAAE,GAAGR,YAAY,EAAE;QAAE,GAAGF,IAAI;QAAEgB,QAAQ,EAAE,CAAEf,IAAI;MAAG,CAAC,CAAE;IAC5D;IAEA,IAAIgB,YAAY,GAAGP,aAAa,CAACM,QAAQ,IAAI,EAAE;IAE/C,IAAKC,YAAY,CAACT,IAAI,CAAEK,eAAgB,CAAC,EAAG;MAC3C;MACAI,YAAY,GAAGA,YAAY,CAACN,MAAM,CAC/BP,CAAC,IAAM,CAAES,eAAe,CAAET,CAAE,CAC/B,CAAC;IACF,CAAC,MAAM;MACN;MACAa,YAAY,GAAG,CAAE,GAAGA,YAAY,EAAEhB,IAAI,CAAE;IACzC;;IAEA;IACA,IAAKgB,YAAY,CAACC,MAAM,KAAK,CAAC,EAAG;MAChC,OAAOhB,YAAY,CAACS,MAAM,CAAIP,CAAC,IAAM,CAAED,eAAe,CAAEC,CAAE,CAAE,CAAC;IAC9D;;IAEA;IACA,OAAOF,YAAY,CAACiB,GAAG,CAAIf,CAAC,IAC3BD,eAAe,CAAEC,CAAE,CAAC,GAAG;MAAE,GAAGA,CAAC;MAAEY,QAAQ,EAAEC;IAAa,CAAC,GAAGb,CAC3D,CAAC;EACF,CAAC;EAED,MAAMM,aAAa,GAAGJ,gBAAgB,CAAEJ,YAAa,CAAC;EAEtD,IAAK,CAAED,IAAI,EAAG;IACb,OAAOQ,sBAAsB,CAAEC,aAAc,CAAC;EAC/C;EAEA,OAAOE,iBAAiB,CAAEF,aAAc,CAAC;AAC1C"}
|
|
@@ -42,8 +42,7 @@ function useGlobalStylesUserConfig() {
|
|
|
42
42
|
globalStylesId,
|
|
43
43
|
isReady,
|
|
44
44
|
settings,
|
|
45
|
-
styles
|
|
46
|
-
behaviors
|
|
45
|
+
styles
|
|
47
46
|
} = (0, _data.useSelect)(select => {
|
|
48
47
|
const {
|
|
49
48
|
getEditedEntityRecord,
|
|
@@ -59,8 +58,7 @@ function useGlobalStylesUserConfig() {
|
|
|
59
58
|
globalStylesId: _globalStylesId,
|
|
60
59
|
isReady: hasResolved,
|
|
61
60
|
settings: record?.settings,
|
|
62
|
-
styles: record?.styles
|
|
63
|
-
behaviors: record?.behaviors
|
|
61
|
+
styles: record?.styles
|
|
64
62
|
};
|
|
65
63
|
}, []);
|
|
66
64
|
const {
|
|
@@ -72,23 +70,20 @@ function useGlobalStylesUserConfig() {
|
|
|
72
70
|
const config = (0, _element.useMemo)(() => {
|
|
73
71
|
return {
|
|
74
72
|
settings: settings !== null && settings !== void 0 ? settings : {},
|
|
75
|
-
styles: styles !== null && styles !== void 0 ? styles : {}
|
|
76
|
-
behaviors: behaviors !== null && behaviors !== void 0 ? behaviors : {}
|
|
73
|
+
styles: styles !== null && styles !== void 0 ? styles : {}
|
|
77
74
|
};
|
|
78
|
-
}, [settings, styles
|
|
75
|
+
}, [settings, styles]);
|
|
79
76
|
const setConfig = (0, _element.useCallback)((callback, options = {}) => {
|
|
80
|
-
var _record$styles, _record$settings
|
|
77
|
+
var _record$styles, _record$settings;
|
|
81
78
|
const record = getEditedEntityRecord('root', 'globalStyles', globalStylesId);
|
|
82
79
|
const currentConfig = {
|
|
83
80
|
styles: (_record$styles = record?.styles) !== null && _record$styles !== void 0 ? _record$styles : {},
|
|
84
|
-
settings: (_record$settings = record?.settings) !== null && _record$settings !== void 0 ? _record$settings : {}
|
|
85
|
-
behaviors: (_record$behaviors = record?.behaviors) !== null && _record$behaviors !== void 0 ? _record$behaviors : {}
|
|
81
|
+
settings: (_record$settings = record?.settings) !== null && _record$settings !== void 0 ? _record$settings : {}
|
|
86
82
|
};
|
|
87
83
|
const updatedConfig = callback(currentConfig);
|
|
88
84
|
editEntityRecord('root', 'globalStyles', globalStylesId, {
|
|
89
85
|
styles: cleanEmptyObject(updatedConfig.styles) || {},
|
|
90
|
-
settings: cleanEmptyObject(updatedConfig.settings) || {}
|
|
91
|
-
behaviors: cleanEmptyObject(updatedConfig.behaviors) || {}
|
|
86
|
+
settings: cleanEmptyObject(updatedConfig.settings) || {}
|
|
92
87
|
}, options);
|
|
93
88
|
}, [globalStylesId]);
|
|
94
89
|
return [isReady, config, setConfig];
|