@wordpress/edit-site 6.33.3 → 6.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-editor/use-site-editor-settings.js +14 -2
- package/build/components/block-editor/use-site-editor-settings.js.map +3 -3
- package/build/components/canvas-loader/index.js +5 -8
- package/build/components/canvas-loader/index.js.map +3 -3
- package/build/components/editor/index.js +2 -40
- package/build/components/editor/index.js.map +3 -3
- package/build/components/layout/index.js +5 -7
- package/build/components/layout/index.js.map +3 -3
- package/build/components/page-patterns/fields.js +4 -3
- package/build/components/page-patterns/fields.js.map +3 -3
- package/build/components/page-templates/fields.js +2 -2
- package/build/components/page-templates/fields.js.map +3 -3
- package/build/components/{sidebar-global-styles-wrapper → sidebar-global-styles}/index.js +22 -46
- package/build/components/sidebar-global-styles/index.js.map +7 -0
- package/build/components/sidebar-navigation-screen-global-styles/content.js +38 -16
- package/build/components/sidebar-navigation-screen-global-styles/content.js.map +3 -3
- package/build/components/sidebar-navigation-screen-global-styles/index.js +6 -7
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +3 -3
- package/build/components/sidebar-navigation-screen-main/index.js +0 -9
- package/build/components/sidebar-navigation-screen-main/index.js.map +3 -3
- package/build/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
- package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +2 -2
- package/build/components/site-editor-routes/stylebook.js +5 -3
- package/build/components/site-editor-routes/stylebook.js.map +3 -3
- package/build/components/site-editor-routes/styles.js +33 -11
- package/build/components/site-editor-routes/styles.js.map +3 -3
- package/build/components/welcome-guide/index.js +0 -2
- package/build/components/welcome-guide/index.js.map +3 -3
- package/build/hooks/commands/use-common-commands.js +10 -12
- package/build/hooks/commands/use-common-commands.js.map +3 -3
- package/build/hooks/commands/use-set-command-context.js +0 -5
- package/build/hooks/commands/use-set-command-context.js.map +2 -2
- package/build/index.js +0 -1
- package/build/index.js.map +2 -2
- package/build/posts.js +0 -1
- package/build/posts.js.map +2 -2
- package/build/store/private-actions.js +0 -8
- package/build/store/private-actions.js.map +2 -2
- package/build/store/private-selectors.js +0 -5
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/reducer.js +0 -8
- package/build/store/reducer.js.map +2 -2
- package/build-module/components/block-editor/use-site-editor-settings.js +14 -2
- package/build-module/components/block-editor/use-site-editor-settings.js.map +2 -2
- package/build-module/components/canvas-loader/index.js +5 -8
- package/build-module/components/canvas-loader/index.js.map +2 -2
- package/build-module/components/editor/index.js +4 -46
- package/build-module/components/editor/index.js.map +2 -2
- package/build-module/components/layout/index.js +5 -7
- package/build-module/components/layout/index.js.map +2 -2
- package/build-module/components/page-patterns/fields.js +5 -7
- package/build-module/components/page-patterns/fields.js.map +2 -2
- package/build-module/components/page-templates/fields.js +6 -6
- package/build-module/components/page-templates/fields.js.map +2 -2
- package/build-module/components/{sidebar-global-styles-wrapper → sidebar-global-styles}/index.js +21 -41
- package/build-module/components/sidebar-global-styles/index.js.map +7 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/content.js +42 -6
- package/build-module/components/sidebar-navigation-screen-global-styles/content.js.map +2 -2
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +5 -6
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +2 -2
- package/build-module/components/sidebar-navigation-screen-main/index.js +1 -10
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +3 -3
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +2 -2
- package/build-module/components/site-editor-routes/stylebook.js +3 -1
- package/build-module/components/site-editor-routes/stylebook.js.map +2 -2
- package/build-module/components/site-editor-routes/styles.js +31 -9
- package/build-module/components/site-editor-routes/styles.js.map +2 -2
- package/build-module/components/welcome-guide/index.js +0 -2
- package/build-module/components/welcome-guide/index.js.map +2 -2
- package/build-module/hooks/commands/use-common-commands.js +13 -12
- package/build-module/hooks/commands/use-common-commands.js.map +2 -2
- package/build-module/hooks/commands/use-set-command-context.js +0 -5
- package/build-module/hooks/commands/use-set-command-context.js.map +2 -2
- package/build-module/index.js +0 -1
- package/build-module/index.js.map +2 -2
- package/build-module/posts.js +0 -1
- package/build-module/posts.js.map +2 -2
- package/build-module/store/private-actions.js +0 -7
- package/build-module/store/private-actions.js.map +2 -2
- package/build-module/store/private-selectors.js +0 -4
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/reducer.js +0 -8
- package/build-module/store/reducer.js.map +2 -2
- package/build-style/posts-rtl.css +13 -50
- package/build-style/posts.css +13 -50
- package/build-style/style-rtl.css +722 -726
- package/build-style/style.css +722 -726
- package/package.json +49 -44
- package/src/components/block-editor/use-site-editor-settings.js +21 -2
- package/src/components/canvas-loader/index.js +5 -9
- package/src/components/editor/index.js +2 -50
- package/src/components/layout/index.js +6 -10
- package/src/components/page-patterns/fields.js +5 -7
- package/src/components/page-templates/fields.js +6 -6
- package/src/components/{sidebar-global-styles-wrapper → sidebar-global-styles}/index.js +16 -48
- package/src/components/{sidebar-global-styles-wrapper → sidebar-global-styles}/style.scss +3 -3
- package/src/components/sidebar-navigation-screen/style.scss +5 -12
- package/src/components/sidebar-navigation-screen-global-styles/content.js +34 -6
- package/src/components/sidebar-navigation-screen-global-styles/index.js +6 -9
- package/src/components/sidebar-navigation-screen-main/index.js +1 -12
- package/src/components/sidebar-navigation-screen-patterns/style.scss +1 -1
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +3 -3
- package/src/components/site-editor-routes/stylebook.js +4 -1
- package/src/components/site-editor-routes/styles.js +35 -9
- package/src/components/site-hub/style.scss +1 -1
- package/src/components/welcome-guide/index.js +0 -2
- package/src/components/welcome-guide/style.scss +1 -2
- package/src/hooks/commands/use-common-commands.js +19 -12
- package/src/hooks/commands/use-set-command-context.js +0 -11
- package/src/index.js +0 -1
- package/src/posts.js +0 -1
- package/src/posts.scss +0 -1
- package/src/store/private-actions.js +0 -14
- package/src/store/private-selectors.js +0 -11
- package/src/store/reducer.js +0 -18
- package/src/style.scss +2 -9
- package/tsconfig.json +3 -11
- package/build/components/editor-canvas-container/index.js +0 -139
- package/build/components/editor-canvas-container/index.js.map +0 -7
- package/build/components/global-styles/background-panel.js +0 -62
- package/build/components/global-styles/background-panel.js.map +0 -7
- package/build/components/global-styles/block-preview-panel.js +0 -87
- package/build/components/global-styles/block-preview-panel.js.map +0 -7
- package/build/components/global-styles/color-indicator-wrapper.js +0 -50
- package/build/components/global-styles/color-indicator-wrapper.js.map +0 -7
- package/build/components/global-styles/color-palette-panel.js +0 -133
- package/build/components/global-styles/color-palette-panel.js.map +0 -7
- package/build/components/global-styles/confirm-reset-shadow-dialog.js +0 -55
- package/build/components/global-styles/confirm-reset-shadow-dialog.js.map +0 -7
- package/build/components/global-styles/dimensions-panel.js +0 -92
- package/build/components/global-styles/dimensions-panel.js.map +0 -7
- package/build/components/global-styles/font-families.js +0 -114
- package/build/components/global-styles/font-families.js.map +0 -7
- package/build/components/global-styles/font-family-item.js +0 -48
- package/build/components/global-styles/font-family-item.js.map +0 -7
- package/build/components/global-styles/font-library-modal/collection-font-variant.js +0 -75
- package/build/components/global-styles/font-library-modal/collection-font-variant.js.map +0 -7
- package/build/components/global-styles/font-library-modal/context.js +0 -386
- package/build/components/global-styles/font-library-modal/context.js.map +0 -7
- package/build/components/global-styles/font-library-modal/font-card.js +0 -76
- package/build/components/global-styles/font-library-modal/font-card.js.map +0 -7
- package/build/components/global-styles/font-library-modal/font-collection.js +0 -504
- package/build/components/global-styles/font-library-modal/font-collection.js.map +0 -7
- package/build/components/global-styles/font-library-modal/font-demo.js +0 -108
- package/build/components/global-styles/font-library-modal/font-demo.js.map +0 -7
- package/build/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +0 -58
- package/build/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +0 -7
- package/build/components/global-styles/font-library-modal/index.js +0 -110
- package/build/components/global-styles/font-library-modal/index.js.map +0 -7
- package/build/components/global-styles/font-library-modal/installed-fonts.js +0 -455
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +0 -7
- package/build/components/global-styles/font-library-modal/library-font-details.js +0 -63
- package/build/components/global-styles/font-library-modal/library-font-details.js.map +0 -7
- package/build/components/global-styles/font-library-modal/library-font-variant.js +0 -78
- package/build/components/global-styles/font-library-modal/library-font-variant.js.map +0 -7
- package/build/components/global-styles/font-library-modal/resolvers.js +0 -115
- package/build/components/global-styles/font-library-modal/resolvers.js.map +0 -7
- package/build/components/global-styles/font-library-modal/upload-fonts.js +0 -205
- package/build/components/global-styles/font-library-modal/upload-fonts.js.map +0 -7
- package/build/components/global-styles/font-library-modal/utils/constants.js +0 -49
- package/build/components/global-styles/font-library-modal/utils/constants.js.map +0 -7
- package/build/components/global-styles/font-library-modal/utils/filter-fonts.js +0 -39
- package/build/components/global-styles/font-library-modal/utils/filter-fonts.js.map +0 -7
- package/build/components/global-styles/font-library-modal/utils/fonts-outline.js +0 -51
- package/build/components/global-styles/font-library-modal/utils/fonts-outline.js.map +0 -7
- package/build/components/global-styles/font-library-modal/utils/index.js +0 -277
- package/build/components/global-styles/font-library-modal/utils/index.js.map +0 -7
- package/build/components/global-styles/font-library-modal/utils/make-families-from-faces.js +0 -42
- package/build/components/global-styles/font-library-modal/utils/make-families-from-faces.js.map +0 -7
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js +0 -117
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js.map +0 -7
- package/build/components/global-styles/font-library-modal/utils/sort-font-faces.js +0 -56
- package/build/components/global-styles/font-library-modal/utils/sort-font-faces.js.map +0 -7
- package/build/components/global-styles/font-library-modal/utils/toggleFont.js +0 -63
- package/build/components/global-styles/font-library-modal/utils/toggleFont.js.map +0 -7
- package/build/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +0 -60
- package/build/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js.map +0 -7
- package/build/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +0 -55
- package/build/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js.map +0 -7
- package/build/components/global-styles/font-sizes/font-size-preview.js +0 -51
- package/build/components/global-styles/font-sizes/font-size-preview.js.map +0 -7
- package/build/components/global-styles/font-sizes/font-size.js +0 -260
- package/build/components/global-styles/font-sizes/font-size.js.map +0 -7
- package/build/components/global-styles/font-sizes/font-sizes-count.js +0 -50
- package/build/components/global-styles/font-sizes/font-sizes-count.js.map +0 -7
- package/build/components/global-styles/font-sizes/font-sizes.js +0 -220
- package/build/components/global-styles/font-sizes/font-sizes.js.map +0 -7
- package/build/components/global-styles/font-sizes/rename-font-size-dialog.js +0 -90
- package/build/components/global-styles/font-sizes/rename-font-size-dialog.js.map +0 -7
- package/build/components/global-styles/gradients-palette-panel.js +0 -144
- package/build/components/global-styles/gradients-palette-panel.js.map +0 -7
- package/build/components/global-styles/header.js +0 -54
- package/build/components/global-styles/header.js.map +0 -7
- package/build/components/global-styles/highlighted-colors.js +0 -57
- package/build/components/global-styles/highlighted-colors.js.map +0 -7
- package/build/components/global-styles/hooks.js +0 -113
- package/build/components/global-styles/hooks.js.map +0 -7
- package/build/components/global-styles/icon-with-current-color.js +0 -53
- package/build/components/global-styles/icon-with-current-color.js.map +0 -7
- package/build/components/global-styles/index.js +0 -39
- package/build/components/global-styles/index.js.map +0 -7
- package/build/components/global-styles/navigation-button.js +0 -48
- package/build/components/global-styles/navigation-button.js.map +0 -7
- package/build/components/global-styles/palette.js +0 -86
- package/build/components/global-styles/palette.js.map +0 -7
- package/build/components/global-styles/preset-colors.js +0 -40
- package/build/components/global-styles/preset-colors.js.map +0 -7
- package/build/components/global-styles/preview-colors.js +0 -82
- package/build/components/global-styles/preview-colors.js.map +0 -7
- package/build/components/global-styles/preview-styles.js +0 -214
- package/build/components/global-styles/preview-styles.js.map +0 -7
- package/build/components/global-styles/preview-typography.js +0 -68
- package/build/components/global-styles/preview-typography.js.map +0 -7
- package/build/components/global-styles/preview-wrapper.js +0 -101
- package/build/components/global-styles/preview-wrapper.js.map +0 -7
- package/build/components/global-styles/root-menu.js +0 -72
- package/build/components/global-styles/root-menu.js.map +0 -7
- package/build/components/global-styles/screen-background.js +0 -59
- package/build/components/global-styles/screen-background.js.map +0 -7
- package/build/components/global-styles/screen-block-list.js +0 -170
- package/build/components/global-styles/screen-block-list.js.map +0 -7
- package/build/components/global-styles/screen-block.js +0 -316
- package/build/components/global-styles/screen-block.js.map +0 -7
- package/build/components/global-styles/screen-color-palette.js +0 -64
- package/build/components/global-styles/screen-color-palette.js.map +0 -7
- package/build/components/global-styles/screen-colors.js +0 -81
- package/build/components/global-styles/screen-colors.js.map +0 -7
- package/build/components/global-styles/screen-css.js +0 -92
- package/build/components/global-styles/screen-css.js.map +0 -7
- package/build/components/global-styles/screen-layout.js +0 -51
- package/build/components/global-styles/screen-layout.js.map +0 -7
- package/build/components/global-styles/screen-revisions/index.js +0 -179
- package/build/components/global-styles/screen-revisions/index.js.map +0 -7
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +0 -192
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +0 -7
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +0 -148
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +0 -7
- package/build/components/global-styles/screen-root.js +0 -99
- package/build/components/global-styles/screen-root.js.map +0 -7
- package/build/components/global-styles/screen-shadows.js +0 -49
- package/build/components/global-styles/screen-shadows.js.map +0 -7
- package/build/components/global-styles/screen-style-variations.js +0 -70
- package/build/components/global-styles/screen-style-variations.js.map +0 -7
- package/build/components/global-styles/screen-typography-element.js +0 -167
- package/build/components/global-styles/screen-typography-element.js.map +0 -7
- package/build/components/global-styles/screen-typography.js +0 -68
- package/build/components/global-styles/screen-typography.js.map +0 -7
- package/build/components/global-styles/shadow-utils.js +0 -125
- package/build/components/global-styles/shadow-utils.js.map +0 -7
- package/build/components/global-styles/shadows-edit-panel.js +0 -501
- package/build/components/global-styles/shadows-edit-panel.js.map +0 -7
- package/build/components/global-styles/shadows-panel.js +0 -206
- package/build/components/global-styles/shadows-panel.js.map +0 -7
- package/build/components/global-styles/size-control/index.js +0 -80
- package/build/components/global-styles/size-control/index.js.map +0 -7
- package/build/components/global-styles/style-variations-container.js +0 -124
- package/build/components/global-styles/style-variations-container.js.map +0 -7
- package/build/components/global-styles/subtitle.js +0 -37
- package/build/components/global-styles/subtitle.js.map +0 -7
- package/build/components/global-styles/typeset.js +0 -78
- package/build/components/global-styles/typeset.js.map +0 -7
- package/build/components/global-styles/typography-elements.js +0 -123
- package/build/components/global-styles/typography-elements.js.map +0 -7
- package/build/components/global-styles/typography-example.js +0 -81
- package/build/components/global-styles/typography-example.js.map +0 -7
- package/build/components/global-styles/typography-panel.js +0 -69
- package/build/components/global-styles/typography-panel.js.map +0 -7
- package/build/components/global-styles/typography-preview.js +0 -80
- package/build/components/global-styles/typography-preview.js.map +0 -7
- package/build/components/global-styles/ui.js +0 -355
- package/build/components/global-styles/ui.js.map +0 -7
- package/build/components/global-styles/utils.js +0 -92
- package/build/components/global-styles/utils.js.map +0 -7
- package/build/components/global-styles/variations/variation.js +0 -118
- package/build/components/global-styles/variations/variation.js.map +0 -7
- package/build/components/global-styles/variations/variations-color.js +0 -61
- package/build/components/global-styles/variations/variations-color.js.map +0 -7
- package/build/components/global-styles/variations/variations-panel.js +0 -71
- package/build/components/global-styles/variations/variations-panel.js.map +0 -7
- package/build/components/global-styles/variations/variations-typography.js +0 -75
- package/build/components/global-styles/variations/variations-typography.js.map +0 -7
- package/build/components/global-styles-renderer/index.js +0 -57
- package/build/components/global-styles-renderer/index.js.map +0 -7
- package/build/components/global-styles-sidebar/default-sidebar.js +0 -68
- package/build/components/global-styles-sidebar/default-sidebar.js.map +0 -7
- package/build/components/global-styles-sidebar/index.js +0 -202
- package/build/components/global-styles-sidebar/index.js.map +0 -7
- package/build/components/revisions/index.js +0 -120
- package/build/components/revisions/index.js.map +0 -7
- package/build/components/sidebar-global-styles-wrapper/index.js.map +0 -7
- package/build/components/style-book/categories.js +0 -86
- package/build/components/style-book/categories.js.map +0 -7
- package/build/components/style-book/color-examples.js +0 -65
- package/build/components/style-book/color-examples.js.map +0 -7
- package/build/components/style-book/constants.js +0 -319
- package/build/components/style-book/constants.js.map +0 -7
- package/build/components/style-book/duotone-examples.js +0 -69
- package/build/components/style-book/duotone-examples.js.map +0 -7
- package/build/components/style-book/examples.js +0 -237
- package/build/components/style-book/examples.js.map +0 -7
- package/build/components/style-book/index.js +0 -644
- package/build/components/style-book/index.js.map +0 -7
- package/build/components/style-book/types.js +0 -17
- package/build/components/style-book/types.js.map +0 -7
- package/build/components/welcome-guide/styles.js +0 -145
- package/build/components/welcome-guide/styles.js.map +0 -7
- package/build/hooks/index.js +0 -3
- package/build/hooks/index.js.map +0 -7
- package/build/hooks/push-changes-to-global-styles/index.js +0 -319
- package/build/hooks/push-changes-to-global-styles/index.js.map +0 -7
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +0 -126
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +0 -7
- package/build/utils/set-nested-value.js +0 -43
- package/build/utils/set-nested-value.js.map +0 -7
- package/build-module/components/editor-canvas-container/index.js +0 -120
- package/build-module/components/editor-canvas-container/index.js.map +0 -7
- package/build-module/components/global-styles/background-panel.js +0 -38
- package/build-module/components/global-styles/background-panel.js.map +0 -7
- package/build-module/components/global-styles/block-preview-panel.js +0 -67
- package/build-module/components/global-styles/block-preview-panel.js.map +0 -7
- package/build-module/components/global-styles/color-indicator-wrapper.js +0 -20
- package/build-module/components/global-styles/color-indicator-wrapper.js.map +0 -7
- package/build-module/components/global-styles/color-palette-panel.js +0 -107
- package/build-module/components/global-styles/color-palette-panel.js.map +0 -7
- package/build-module/components/global-styles/confirm-reset-shadow-dialog.js +0 -35
- package/build-module/components/global-styles/confirm-reset-shadow-dialog.js.map +0 -7
- package/build-module/components/global-styles/dimensions-panel.js +0 -72
- package/build-module/components/global-styles/dimensions-panel.js.map +0 -7
- package/build-module/components/global-styles/font-families.js +0 -92
- package/build-module/components/global-styles/font-families.js.map +0 -7
- package/build-module/components/global-styles/font-family-item.js +0 -32
- package/build-module/components/global-styles/font-family-item.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js +0 -45
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/context.js +0 -372
- package/build-module/components/global-styles/font-library-modal/context.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/font-card.js +0 -53
- package/build-module/components/global-styles/font-library-modal/font-card.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/font-collection.js +0 -505
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/font-demo.js +0 -91
- package/build-module/components/global-styles/font-library-modal/font-demo.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +0 -45
- package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/index.js +0 -83
- package/build-module/components/global-styles/font-library-modal/index.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +0 -444
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/library-font-details.js +0 -36
- package/build-module/components/global-styles/font-library-modal/library-font-details.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js +0 -48
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/resolvers.js +0 -76
- package/build-module/components/global-styles/font-library-modal/resolvers.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js +0 -185
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/utils/constants.js +0 -23
- package/build-module/components/global-styles/font-library-modal/utils/constants.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js +0 -19
- package/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/utils/fonts-outline.js +0 -26
- package/build-module/components/global-styles/font-library-modal/utils/fonts-outline.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/utils/index.js +0 -241
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/utils/make-families-from-faces.js +0 -22
- package/build-module/components/global-styles/font-library-modal/utils/make-families-from-faces.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js +0 -90
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/utils/sort-font-faces.js +0 -32
- package/build-module/components/global-styles/font-library-modal/utils/sort-font-faces.js.map +0 -7
- package/build-module/components/global-styles/font-library-modal/utils/toggleFont.js +0 -39
- package/build-module/components/global-styles/font-library-modal/utils/toggleFont.js.map +0 -7
- package/build-module/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +0 -40
- package/build-module/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js.map +0 -7
- package/build-module/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +0 -35
- package/build-module/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js.map +0 -7
- package/build-module/components/global-styles/font-sizes/font-size-preview.js +0 -34
- package/build-module/components/global-styles/font-sizes/font-size-preview.js.map +0 -7
- package/build-module/components/global-styles/font-sizes/font-size.js +0 -240
- package/build-module/components/global-styles/font-sizes/font-size.js.map +0 -7
- package/build-module/components/global-styles/font-sizes/font-sizes-count.js +0 -25
- package/build-module/components/global-styles/font-sizes/font-sizes-count.js.map +0 -7
- package/build-module/components/global-styles/font-sizes/font-sizes.js +0 -205
- package/build-module/components/global-styles/font-sizes/font-sizes.js.map +0 -7
- package/build-module/components/global-styles/font-sizes/rename-font-size-dialog.js +0 -76
- package/build-module/components/global-styles/font-sizes/rename-font-size-dialog.js.map +0 -7
- package/build-module/components/global-styles/gradients-palette-panel.js +0 -119
- package/build-module/components/global-styles/gradients-palette-panel.js.map +0 -7
- package/build-module/components/global-styles/header.js +0 -41
- package/build-module/components/global-styles/header.js.map +0 -7
- package/build-module/components/global-styles/highlighted-colors.js +0 -37
- package/build-module/components/global-styles/highlighted-colors.js.map +0 -7
- package/build-module/components/global-styles/hooks.js +0 -77
- package/build-module/components/global-styles/hooks.js.map +0 -7
- package/build-module/components/global-styles/icon-with-current-color.js +0 -19
- package/build-module/components/global-styles/icon-with-current-color.js.map +0 -7
- package/build-module/components/global-styles/index.js +0 -5
- package/build-module/components/global-styles/index.js.map +0 -7
- package/build-module/components/global-styles/navigation-button.js +0 -28
- package/build-module/components/global-styles/navigation-button.js.map +0 -7
- package/build-module/components/global-styles/palette.js +0 -63
- package/build-module/components/global-styles/palette.js.map +0 -7
- package/build-module/components/global-styles/preset-colors.js +0 -20
- package/build-module/components/global-styles/preset-colors.js.map +0 -7
- package/build-module/components/global-styles/preview-colors.js +0 -55
- package/build-module/components/global-styles/preview-colors.js.map +0 -7
- package/build-module/components/global-styles/preview-styles.js +0 -188
- package/build-module/components/global-styles/preview-styles.js.map +0 -7
- package/build-module/components/global-styles/preview-typography.js +0 -38
- package/build-module/components/global-styles/preview-typography.js.map +0 -7
- package/build-module/components/global-styles/preview-wrapper.js +0 -85
- package/build-module/components/global-styles/preview-wrapper.js.map +0 -7
- package/build-module/components/global-styles/root-menu.js +0 -58
- package/build-module/components/global-styles/root-menu.js.map +0 -7
- package/build-module/components/global-styles/screen-background.js +0 -29
- package/build-module/components/global-styles/screen-background.js.map +0 -7
- package/build-module/components/global-styles/screen-block-list.js +0 -150
- package/build-module/components/global-styles/screen-block-list.js.map +0 -7
- package/build-module/components/global-styles/screen-block.js +0 -293
- package/build-module/components/global-styles/screen-block.js.map +0 -7
- package/build-module/components/global-styles/screen-color-palette.js +0 -34
- package/build-module/components/global-styles/screen-color-palette.js.map +0 -7
- package/build-module/components/global-styles/screen-colors.js +0 -51
- package/build-module/components/global-styles/screen-colors.js.map +0 -7
- package/build-module/components/global-styles/screen-css.js +0 -62
- package/build-module/components/global-styles/screen-css.js.map +0 -7
- package/build-module/components/global-styles/screen-layout.js +0 -21
- package/build-module/components/global-styles/screen-layout.js.map +0 -7
- package/build-module/components/global-styles/screen-revisions/index.js +0 -155
- package/build-module/components/global-styles/screen-revisions/index.js.map +0 -7
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +0 -172
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +0 -7
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +0 -128
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +0 -7
- package/build-module/components/global-styles/screen-root.js +0 -79
- package/build-module/components/global-styles/screen-root.js.map +0 -7
- package/build-module/components/global-styles/screen-shadows.js +0 -14
- package/build-module/components/global-styles/screen-shadows.js.map +0 -7
- package/build-module/components/global-styles/screen-style-variations.js +0 -43
- package/build-module/components/global-styles/screen-style-variations.js.map +0 -7
- package/build-module/components/global-styles/screen-typography-element.js +0 -141
- package/build-module/components/global-styles/screen-typography-element.js.map +0 -7
- package/build-module/components/global-styles/screen-typography.js +0 -38
- package/build-module/components/global-styles/screen-typography.js.map +0 -7
- package/build-module/components/global-styles/shadow-utils.js +0 -98
- package/build-module/components/global-styles/shadow-utils.js.map +0 -7
- package/build-module/components/global-styles/shadows-edit-panel.js +0 -500
- package/build-module/components/global-styles/shadows-edit-panel.js.map +0 -7
- package/build-module/components/global-styles/shadows-panel.js +0 -185
- package/build-module/components/global-styles/shadows-panel.js.map +0 -7
- package/build-module/components/global-styles/size-control/index.js +0 -70
- package/build-module/components/global-styles/size-control/index.js.map +0 -7
- package/build-module/components/global-styles/style-variations-container.js +0 -94
- package/build-module/components/global-styles/style-variations-container.js.map +0 -7
- package/build-module/components/global-styles/subtitle.js +0 -17
- package/build-module/components/global-styles/subtitle.js.map +0 -7
- package/build-module/components/global-styles/typeset.js +0 -54
- package/build-module/components/global-styles/typeset.js.map +0 -7
- package/build-module/components/global-styles/typography-elements.js +0 -98
- package/build-module/components/global-styles/typography-elements.js.map +0 -7
- package/build-module/components/global-styles/typography-example.js +0 -61
- package/build-module/components/global-styles/typography-example.js.map +0 -7
- package/build-module/components/global-styles/typography-panel.js +0 -49
- package/build-module/components/global-styles/typography-panel.js.map +0 -7
- package/build-module/components/global-styles/typography-preview.js +0 -60
- package/build-module/components/global-styles/typography-preview.js.map +0 -7
- package/build-module/components/global-styles/ui.js +0 -334
- package/build-module/components/global-styles/ui.js.map +0 -7
- package/build-module/components/global-styles/utils.js +0 -66
- package/build-module/components/global-styles/utils.js.map +0 -7
- package/build-module/components/global-styles/variations/variation.js +0 -88
- package/build-module/components/global-styles/variations/variation.js.map +0 -7
- package/build-module/components/global-styles/variations/variations-color.js +0 -34
- package/build-module/components/global-styles/variations/variations-color.js.map +0 -7
- package/build-module/components/global-styles/variations/variations-panel.js +0 -46
- package/build-module/components/global-styles/variations/variations-panel.js.map +0 -7
- package/build-module/components/global-styles/variations/variations-typography.js +0 -48
- package/build-module/components/global-styles/variations/variations-typography.js.map +0 -7
- package/build-module/components/global-styles-renderer/index.js +0 -33
- package/build-module/components/global-styles-renderer/index.js.map +0 -7
- package/build-module/components/global-styles-sidebar/default-sidebar.js +0 -48
- package/build-module/components/global-styles-sidebar/default-sidebar.js.map +0 -7
- package/build-module/components/global-styles-sidebar/index.js +0 -175
- package/build-module/components/global-styles-sidebar/index.js.map +0 -7
- package/build-module/components/revisions/index.js +0 -96
- package/build-module/components/revisions/index.js.map +0 -7
- package/build-module/components/sidebar-global-styles-wrapper/index.js.map +0 -7
- package/build-module/components/style-book/categories.js +0 -64
- package/build-module/components/style-book/categories.js.map +0 -7
- package/build-module/components/style-book/color-examples.js +0 -38
- package/build-module/components/style-book/color-examples.js.map +0 -7
- package/build-module/components/style-book/constants.js +0 -290
- package/build-module/components/style-book/constants.js.map +0 -7
- package/build-module/components/style-book/duotone-examples.js +0 -49
- package/build-module/components/style-book/duotone-examples.js.map +0 -7
- package/build-module/components/style-book/examples.js +0 -208
- package/build-module/components/style-book/examples.js.map +0 -7
- package/build-module/components/style-book/index.js +0 -635
- package/build-module/components/style-book/index.js.map +0 -7
- package/build-module/components/style-book/types.js +0 -1
- package/build-module/components/style-book/types.js.map +0 -7
- package/build-module/components/welcome-guide/styles.js +0 -115
- package/build-module/components/welcome-guide/styles.js.map +0 -7
- package/build-module/hooks/index.js +0 -2
- package/build-module/hooks/index.js.map +0 -7
- package/build-module/hooks/push-changes-to-global-styles/index.js +0 -305
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +0 -7
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +0 -99
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +0 -7
- package/build-module/utils/set-nested-value.js +0 -23
- package/build-module/utils/set-nested-value.js.map +0 -7
- package/build-types/components/style-book/categories.d.ts +0 -18
- package/build-types/components/style-book/categories.d.ts.map +0 -1
- package/build-types/components/style-book/color-examples.d.ts +0 -7
- package/build-types/components/style-book/color-examples.d.ts.map +0 -1
- package/build-types/components/style-book/constants.d.ts +0 -11
- package/build-types/components/style-book/constants.d.ts.map +0 -1
- package/build-types/components/style-book/duotone-examples.d.ts +0 -9
- package/build-types/components/style-book/duotone-examples.d.ts.map +0 -1
- package/build-types/components/style-book/examples.d.ts +0 -12
- package/build-types/components/style-book/examples.d.ts.map +0 -1
- package/build-types/components/style-book/types.d.ts +0 -72
- package/build-types/components/style-book/types.d.ts.map +0 -1
- package/lib/inflate.js +0 -3333
- package/lib/lib-font.browser.js +0 -3861
- package/lib/unbrotli.js +0 -2039
- package/src/components/editor-canvas-container/index.js +0 -149
- package/src/components/editor-canvas-container/style.scss +0 -43
- package/src/components/global-styles/README.md +0 -17
- package/src/components/global-styles/background-panel.js +0 -55
- package/src/components/global-styles/block-preview-panel.js +0 -81
- package/src/components/global-styles/color-indicator-wrapper.js +0 -23
- package/src/components/global-styles/color-palette-panel.js +0 -110
- package/src/components/global-styles/confirm-reset-shadow-dialog.js +0 -37
- package/src/components/global-styles/dimensions-panel.js +0 -86
- package/src/components/global-styles/font-families.js +0 -128
- package/src/components/global-styles/font-family-item.js +0 -47
- package/src/components/global-styles/font-library-modal/collection-font-variant.js +0 -51
- package/src/components/global-styles/font-library-modal/context.js +0 -540
- package/src/components/global-styles/font-library-modal/font-card.js +0 -67
- package/src/components/global-styles/font-library-modal/font-collection.js +0 -575
- package/src/components/global-styles/font-library-modal/font-demo.js +0 -116
- package/src/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +0 -57
- package/src/components/global-styles/font-library-modal/index.js +0 -106
- package/src/components/global-styles/font-library-modal/installed-fonts.js +0 -518
- package/src/components/global-styles/font-library-modal/library-font-details.js +0 -45
- package/src/components/global-styles/font-library-modal/library-font-variant.js +0 -60
- package/src/components/global-styles/font-library-modal/resolvers.js +0 -78
- package/src/components/global-styles/font-library-modal/style.scss +0 -220
- package/src/components/global-styles/font-library-modal/upload-fonts.js +0 -253
- package/src/components/global-styles/font-library-modal/utils/constants.js +0 -23
- package/src/components/global-styles/font-library-modal/utils/filter-fonts.js +0 -35
- package/src/components/global-styles/font-library-modal/utils/fonts-outline.js +0 -22
- package/src/components/global-styles/font-library-modal/utils/index.js +0 -333
- package/src/components/global-styles/font-library-modal/utils/make-families-from-faces.js +0 -27
- package/src/components/global-styles/font-library-modal/utils/preview-styles.js +0 -152
- package/src/components/global-styles/font-library-modal/utils/sort-font-faces.js +0 -37
- package/src/components/global-styles/font-library-modal/utils/test/filter-fonts.spec.js +0 -99
- package/src/components/global-styles/font-library-modal/utils/test/fonts-outline.spec.js +0 -109
- package/src/components/global-styles/font-library-modal/utils/test/getDisplaySrcFromFontFace.spec.js +0 -42
- package/src/components/global-styles/font-library-modal/utils/test/getFontFaceVariantName.spec.js +0 -30
- package/src/components/global-styles/font-library-modal/utils/test/isUrlEncoded.spec.js +0 -31
- package/src/components/global-styles/font-library-modal/utils/test/makeFamiliesFromFaces.spec.js +0 -57
- package/src/components/global-styles/font-library-modal/utils/test/mergeFontFaces.spec.js +0 -56
- package/src/components/global-styles/font-library-modal/utils/test/mergeFontFamilies.spec.js +0 -108
- package/src/components/global-styles/font-library-modal/utils/test/preview-styles.spec.js +0 -216
- package/src/components/global-styles/font-library-modal/utils/test/setUIValuesNeeded.spec.js +0 -41
- package/src/components/global-styles/font-library-modal/utils/test/sort-font-faces.js +0 -74
- package/src/components/global-styles/font-library-modal/utils/test/toggleFont.spec.js +0 -141
- package/src/components/global-styles/font-library-modal/utils/toggleFont.js +0 -90
- package/src/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +0 -43
- package/src/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +0 -37
- package/src/components/global-styles/font-sizes/font-size-preview.js +0 -43
- package/src/components/global-styles/font-sizes/font-size.js +0 -265
- package/src/components/global-styles/font-sizes/font-sizes-count.js +0 -37
- package/src/components/global-styles/font-sizes/font-sizes.js +0 -261
- package/src/components/global-styles/font-sizes/rename-font-size-dialog.js +0 -70
- package/src/components/global-styles/gradients-palette-panel.js +0 -123
- package/src/components/global-styles/header.js +0 -48
- package/src/components/global-styles/highlighted-colors.js +0 -39
- package/src/components/global-styles/hooks.js +0 -111
- package/src/components/global-styles/icon-with-current-color.js +0 -21
- package/src/components/global-styles/index.js +0 -1
- package/src/components/global-styles/navigation-button.js +0 -38
- package/src/components/global-styles/palette.js +0 -90
- package/src/components/global-styles/preset-colors.js +0 -18
- package/src/components/global-styles/preview-colors.js +0 -58
- package/src/components/global-styles/preview-styles.js +0 -185
- package/src/components/global-styles/preview-typography.js +0 -39
- package/src/components/global-styles/preview-wrapper.js +0 -126
- package/src/components/global-styles/root-menu.js +0 -84
- package/src/components/global-styles/screen-background.js +0 -37
- package/src/components/global-styles/screen-block-list.js +0 -187
- package/src/components/global-styles/screen-block.js +0 -358
- package/src/components/global-styles/screen-color-palette.js +0 -42
- package/src/components/global-styles/screen-colors.js +0 -55
- package/src/components/global-styles/screen-css.js +0 -67
- package/src/components/global-styles/screen-layout.js +0 -30
- package/src/components/global-styles/screen-revisions/index.js +0 -202
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +0 -238
- package/src/components/global-styles/screen-revisions/style.scss +0 -194
- package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +0 -228
- package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +0 -159
- package/src/components/global-styles/screen-root.js +0 -102
- package/src/components/global-styles/screen-shadows.js +0 -13
- package/src/components/global-styles/screen-style-variations.js +0 -52
- package/src/components/global-styles/screen-typography-element.js +0 -121
- package/src/components/global-styles/screen-typography.js +0 -45
- package/src/components/global-styles/shadow-utils.js +0 -158
- package/src/components/global-styles/shadows-edit-panel.js +0 -525
- package/src/components/global-styles/shadows-panel.js +0 -196
- package/src/components/global-styles/size-control/index.js +0 -89
- package/src/components/global-styles/stories/index.story.js +0 -427
- package/src/components/global-styles/style-variations-container.js +0 -132
- package/src/components/global-styles/style.scss +0 -265
- package/src/components/global-styles/subtitle.js +0 -17
- package/src/components/global-styles/test/shadow-utils.spec.js +0 -251
- package/src/components/global-styles/test/utils.spec.js +0 -59
- package/src/components/global-styles/typeset.js +0 -73
- package/src/components/global-styles/typography-elements.js +0 -102
- package/src/components/global-styles/typography-example.js +0 -76
- package/src/components/global-styles/typography-panel.js +0 -54
- package/src/components/global-styles/typography-preview.js +0 -70
- package/src/components/global-styles/ui.js +0 -448
- package/src/components/global-styles/utils.js +0 -88
- package/src/components/global-styles/variations/style.scss +0 -43
- package/src/components/global-styles/variations/variation.js +0 -108
- package/src/components/global-styles/variations/variations-color.js +0 -45
- package/src/components/global-styles/variations/variations-panel.js +0 -65
- package/src/components/global-styles/variations/variations-typography.js +0 -54
- package/src/components/global-styles-renderer/index.js +0 -42
- package/src/components/global-styles-sidebar/default-sidebar.js +0 -51
- package/src/components/global-styles-sidebar/index.js +0 -206
- package/src/components/global-styles-sidebar/style.scss +0 -80
- package/src/components/revisions/index.js +0 -109
- package/src/components/style-book/categories.ts +0 -97
- package/src/components/style-book/color-examples.tsx +0 -57
- package/src/components/style-book/constants.ts +0 -308
- package/src/components/style-book/duotone-examples.tsx +0 -57
- package/src/components/style-book/examples.tsx +0 -273
- package/src/components/style-book/index.js +0 -804
- package/src/components/style-book/style.scss +0 -44
- package/src/components/style-book/test/categories.js +0 -166
- package/src/components/style-book/types.ts +0 -80
- package/src/components/welcome-guide/styles.js +0 -139
- package/src/hooks/index.js +0 -4
- package/src/hooks/push-changes-to-global-styles/index.js +0 -388
- package/src/hooks/push-changes-to-global-styles/style.scss +0 -4
- package/src/hooks/use-theme-style-variations/test/use-theme-style-variations-by-property.js +0 -271
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +0 -175
- package/src/utils/set-nested-value.js +0 -39
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export function getFontsOutline( fonts ) {
|
|
2
|
-
return fonts.reduce(
|
|
3
|
-
( acc, font ) => ( {
|
|
4
|
-
...acc,
|
|
5
|
-
[ font.slug ]: ( font?.fontFace || [] ).reduce(
|
|
6
|
-
( faces, face ) => ( {
|
|
7
|
-
...faces,
|
|
8
|
-
[ `${ face.fontStyle }-${ face.fontWeight }` ]: true,
|
|
9
|
-
} ),
|
|
10
|
-
{}
|
|
11
|
-
),
|
|
12
|
-
} ),
|
|
13
|
-
{}
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function isFontFontFaceInOutline( slug, face, outline ) {
|
|
18
|
-
if ( ! face ) {
|
|
19
|
-
return !! outline[ slug ];
|
|
20
|
-
}
|
|
21
|
-
return !! outline[ slug ]?.[ `${ face.fontStyle }-${ face.fontWeight }` ];
|
|
22
|
-
}
|
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { FONT_WEIGHTS, FONT_STYLES } from './constants';
|
|
10
|
-
import { unlock } from '../../../../lock-unlock';
|
|
11
|
-
import { fetchInstallFontFace } from '../resolvers';
|
|
12
|
-
import { formatFontFaceName } from './preview-styles';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Browser dependencies
|
|
16
|
-
*/
|
|
17
|
-
const { File } = window;
|
|
18
|
-
const { kebabCase } = unlock( componentsPrivateApis );
|
|
19
|
-
|
|
20
|
-
export 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
|
-
|
|
30
|
-
export function isUrlEncoded( url ) {
|
|
31
|
-
if ( typeof url !== 'string' ) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
return url !== decodeURIComponent( url );
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function getFontFaceVariantName( face ) {
|
|
38
|
-
const weightName = FONT_WEIGHTS[ face.fontWeight ] || face.fontWeight;
|
|
39
|
-
const styleName =
|
|
40
|
-
face.fontStyle === 'normal'
|
|
41
|
-
? ''
|
|
42
|
-
: FONT_STYLES[ face.fontStyle ] || face.fontStyle;
|
|
43
|
-
return `${ weightName } ${ styleName }`;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function mergeFontFaces( existing = [], incoming = [] ) {
|
|
47
|
-
const map = new Map();
|
|
48
|
-
for ( const face of existing ) {
|
|
49
|
-
map.set( `${ face.fontWeight }${ face.fontStyle }`, face );
|
|
50
|
-
}
|
|
51
|
-
for ( const face of incoming ) {
|
|
52
|
-
// This will overwrite if the src already exists, keeping it unique.
|
|
53
|
-
map.set( `${ face.fontWeight }${ face.fontStyle }`, face );
|
|
54
|
-
}
|
|
55
|
-
return Array.from( map.values() );
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function mergeFontFamilies( existing = [], incoming = [] ) {
|
|
59
|
-
const map = new Map();
|
|
60
|
-
// Add the existing array to the map.
|
|
61
|
-
for ( const font of existing ) {
|
|
62
|
-
map.set( font.slug, { ...font } );
|
|
63
|
-
}
|
|
64
|
-
// Add the incoming array to the map, overwriting existing values excepting fontFace that need to be merged.
|
|
65
|
-
for ( const font of incoming ) {
|
|
66
|
-
if ( map.has( font.slug ) ) {
|
|
67
|
-
const { fontFace: incomingFontFaces, ...restIncoming } = font;
|
|
68
|
-
const existingFont = map.get( font.slug );
|
|
69
|
-
// Merge the fontFaces existing with the incoming fontFaces.
|
|
70
|
-
const mergedFontFaces = mergeFontFaces(
|
|
71
|
-
existingFont.fontFace,
|
|
72
|
-
incomingFontFaces
|
|
73
|
-
);
|
|
74
|
-
// Except for the fontFace key all the other keys are overwritten with the incoming values.
|
|
75
|
-
map.set( font.slug, {
|
|
76
|
-
...restIncoming,
|
|
77
|
-
fontFace: mergedFontFaces,
|
|
78
|
-
} );
|
|
79
|
-
} else {
|
|
80
|
-
map.set( font.slug, { ...font } );
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return Array.from( map.values() );
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/*
|
|
87
|
-
* Loads the font face from a URL and adds it to the browser.
|
|
88
|
-
* It also adds it to the iframe document.
|
|
89
|
-
*/
|
|
90
|
-
export async function loadFontFaceInBrowser( fontFace, source, addTo = 'all' ) {
|
|
91
|
-
let dataSource;
|
|
92
|
-
|
|
93
|
-
if ( typeof source === 'string' ) {
|
|
94
|
-
dataSource = `url(${ source })`;
|
|
95
|
-
// eslint-disable-next-line no-undef
|
|
96
|
-
} else if ( source instanceof File ) {
|
|
97
|
-
dataSource = await source.arrayBuffer();
|
|
98
|
-
} else {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const newFont = new window.FontFace(
|
|
103
|
-
formatFontFaceName( fontFace.fontFamily ),
|
|
104
|
-
dataSource,
|
|
105
|
-
{
|
|
106
|
-
style: fontFace.fontStyle,
|
|
107
|
-
weight: fontFace.fontWeight,
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
const loadedFace = await newFont.load();
|
|
112
|
-
|
|
113
|
-
if ( addTo === 'document' || addTo === 'all' ) {
|
|
114
|
-
document.fonts.add( loadedFace );
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if ( addTo === 'iframe' || addTo === 'all' ) {
|
|
118
|
-
const iframeDocument = document.querySelector(
|
|
119
|
-
'iframe[name="editor-canvas"]'
|
|
120
|
-
).contentDocument;
|
|
121
|
-
iframeDocument.fonts.add( loadedFace );
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/*
|
|
126
|
-
* Unloads the font face and remove it from the browser.
|
|
127
|
-
* It also removes it from the iframe document.
|
|
128
|
-
*
|
|
129
|
-
* Note that Font faces that were added to the set using the CSS @font-face rule
|
|
130
|
-
* remain connected to the corresponding CSS, and cannot be deleted.
|
|
131
|
-
*
|
|
132
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/delete.
|
|
133
|
-
*/
|
|
134
|
-
export function unloadFontFaceInBrowser( fontFace, removeFrom = 'all' ) {
|
|
135
|
-
const unloadFontFace = ( fonts ) => {
|
|
136
|
-
fonts.forEach( ( f ) => {
|
|
137
|
-
if (
|
|
138
|
-
f.family === formatFontFaceName( fontFace?.fontFamily ) &&
|
|
139
|
-
f.weight === fontFace?.fontWeight &&
|
|
140
|
-
f.style === fontFace?.fontStyle
|
|
141
|
-
) {
|
|
142
|
-
fonts.delete( f );
|
|
143
|
-
}
|
|
144
|
-
} );
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
if ( removeFrom === 'document' || removeFrom === 'all' ) {
|
|
148
|
-
unloadFontFace( document.fonts );
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if ( removeFrom === 'iframe' || removeFrom === 'all' ) {
|
|
152
|
-
const iframeDocument = document.querySelector(
|
|
153
|
-
'iframe[name="editor-canvas"]'
|
|
154
|
-
).contentDocument;
|
|
155
|
-
unloadFontFace( iframeDocument.fonts );
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Retrieves the display source from a font face src.
|
|
161
|
-
*
|
|
162
|
-
* @param {string|string[]} input - The font face src.
|
|
163
|
-
* @return {string|undefined} The display source or undefined if the input is invalid.
|
|
164
|
-
*/
|
|
165
|
-
export function getDisplaySrcFromFontFace( input ) {
|
|
166
|
-
if ( ! input ) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
let src;
|
|
171
|
-
if ( Array.isArray( input ) ) {
|
|
172
|
-
src = input[ 0 ];
|
|
173
|
-
} else {
|
|
174
|
-
src = input;
|
|
175
|
-
}
|
|
176
|
-
// It's expected theme fonts will already be loaded in the browser.
|
|
177
|
-
if ( src.startsWith( 'file:.' ) ) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
if ( ! isUrlEncoded( src ) ) {
|
|
181
|
-
src = encodeURI( src );
|
|
182
|
-
}
|
|
183
|
-
return src;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export function makeFontFamilyFormData( fontFamily ) {
|
|
187
|
-
const formData = new FormData();
|
|
188
|
-
|
|
189
|
-
const { fontFace, category, ...familyWithValidParameters } = fontFamily;
|
|
190
|
-
const fontFamilySettings = {
|
|
191
|
-
...familyWithValidParameters,
|
|
192
|
-
slug: kebabCase( fontFamily.slug ),
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
formData.append(
|
|
196
|
-
'font_family_settings',
|
|
197
|
-
JSON.stringify( fontFamilySettings )
|
|
198
|
-
);
|
|
199
|
-
return formData;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export function makeFontFacesFormData( font ) {
|
|
203
|
-
if ( font?.fontFace ) {
|
|
204
|
-
const fontFacesFormData = font.fontFace.map( ( item, faceIndex ) => {
|
|
205
|
-
const face = { ...item };
|
|
206
|
-
const formData = new FormData();
|
|
207
|
-
if ( face.file ) {
|
|
208
|
-
// Normalize to an array, since face.file may be a single file or an array of files.
|
|
209
|
-
const files = Array.isArray( face.file )
|
|
210
|
-
? face.file
|
|
211
|
-
: [ face.file ];
|
|
212
|
-
const src = [];
|
|
213
|
-
|
|
214
|
-
files.forEach( ( file, key ) => {
|
|
215
|
-
// Slugified file name because the it might contain spaces or characters treated differently on the server.
|
|
216
|
-
const fileId = `file-${ faceIndex }-${ key }`;
|
|
217
|
-
// Add the files to the formData
|
|
218
|
-
formData.append( fileId, file, file.name );
|
|
219
|
-
src.push( fileId );
|
|
220
|
-
} );
|
|
221
|
-
|
|
222
|
-
face.src = src.length === 1 ? src[ 0 ] : src;
|
|
223
|
-
delete face.file;
|
|
224
|
-
|
|
225
|
-
formData.append( 'font_face_settings', JSON.stringify( face ) );
|
|
226
|
-
} else {
|
|
227
|
-
formData.append( 'font_face_settings', JSON.stringify( face ) );
|
|
228
|
-
}
|
|
229
|
-
return formData;
|
|
230
|
-
} );
|
|
231
|
-
|
|
232
|
-
return fontFacesFormData;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export async function batchInstallFontFaces( fontFamilyId, fontFacesData ) {
|
|
237
|
-
const responses = [];
|
|
238
|
-
|
|
239
|
-
/*
|
|
240
|
-
* Uses the same response format as Promise.allSettled, but executes requests in sequence to work
|
|
241
|
-
* around a race condition that can cause an error when the fonts directory doesn't exist yet.
|
|
242
|
-
*/
|
|
243
|
-
for ( const faceData of fontFacesData ) {
|
|
244
|
-
try {
|
|
245
|
-
const response = await fetchInstallFontFace(
|
|
246
|
-
fontFamilyId,
|
|
247
|
-
faceData
|
|
248
|
-
);
|
|
249
|
-
responses.push( { status: 'fulfilled', value: response } );
|
|
250
|
-
} catch ( error ) {
|
|
251
|
-
responses.push( { status: 'rejected', reason: error } );
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const results = {
|
|
256
|
-
errors: [],
|
|
257
|
-
successes: [],
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
responses.forEach( ( result, index ) => {
|
|
261
|
-
if ( result.status === 'fulfilled' ) {
|
|
262
|
-
const response = result.value;
|
|
263
|
-
if ( response.id ) {
|
|
264
|
-
results.successes.push( response );
|
|
265
|
-
} else {
|
|
266
|
-
results.errors.push( {
|
|
267
|
-
data: fontFacesData[ index ],
|
|
268
|
-
message: `Error: ${ response.message }`,
|
|
269
|
-
} );
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
// Handle network errors or other fetch-related errors
|
|
273
|
-
results.errors.push( {
|
|
274
|
-
data: fontFacesData[ index ],
|
|
275
|
-
message: result.reason.message,
|
|
276
|
-
} );
|
|
277
|
-
}
|
|
278
|
-
} );
|
|
279
|
-
|
|
280
|
-
return results;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/*
|
|
284
|
-
* Downloads a font face asset from a URL to the client and returns a File object.
|
|
285
|
-
*/
|
|
286
|
-
export async function downloadFontFaceAssets( src ) {
|
|
287
|
-
// Normalize to an array, since `src` could be a string or array.
|
|
288
|
-
src = Array.isArray( src ) ? src : [ src ];
|
|
289
|
-
|
|
290
|
-
const files = await Promise.all(
|
|
291
|
-
src.map( async ( url ) => {
|
|
292
|
-
return fetch( new Request( url ) )
|
|
293
|
-
.then( ( response ) => {
|
|
294
|
-
if ( ! response.ok ) {
|
|
295
|
-
throw new Error(
|
|
296
|
-
`Error downloading font face asset from ${ url }. Server responded with status: ${ response.status }`
|
|
297
|
-
);
|
|
298
|
-
}
|
|
299
|
-
return response.blob();
|
|
300
|
-
} )
|
|
301
|
-
.then( ( blob ) => {
|
|
302
|
-
const filename = url.split( '/' ).pop();
|
|
303
|
-
const file = new File( [ blob ], filename, {
|
|
304
|
-
type: blob.type,
|
|
305
|
-
} );
|
|
306
|
-
return file;
|
|
307
|
-
} );
|
|
308
|
-
} )
|
|
309
|
-
);
|
|
310
|
-
|
|
311
|
-
// If we only have one file return it (not the array). Otherwise return all of them in the array.
|
|
312
|
-
return files.length === 1 ? files[ 0 ] : files;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/*
|
|
316
|
-
* Determine if a given Font Face is present in a given collection.
|
|
317
|
-
* We determine that a font face has been installed by comparing the fontWeight and fontStyle
|
|
318
|
-
*
|
|
319
|
-
* @param {Object} fontFace The Font Face to seek
|
|
320
|
-
* @param {Array} collection The Collection to seek in
|
|
321
|
-
* @returns True if the font face is found in the collection. Otherwise False.
|
|
322
|
-
*/
|
|
323
|
-
export function checkFontFaceInstalled( fontFace, collection ) {
|
|
324
|
-
return (
|
|
325
|
-
-1 !==
|
|
326
|
-
collection.findIndex( ( collectionFontFace ) => {
|
|
327
|
-
return (
|
|
328
|
-
collectionFontFace.fontWeight === fontFace.fontWeight &&
|
|
329
|
-
collectionFontFace.fontStyle === fontFace.fontStyle
|
|
330
|
-
);
|
|
331
|
-
} )
|
|
332
|
-
);
|
|
333
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { unlock } from '../../../../lock-unlock';
|
|
10
|
-
|
|
11
|
-
const { kebabCase } = unlock( componentsPrivateApis );
|
|
12
|
-
|
|
13
|
-
export default function makeFamiliesFromFaces( fontFaces ) {
|
|
14
|
-
const fontFamiliesObject = fontFaces.reduce( ( acc, item ) => {
|
|
15
|
-
if ( ! acc[ item.fontFamily ] ) {
|
|
16
|
-
acc[ item.fontFamily ] = {
|
|
17
|
-
name: item.fontFamily,
|
|
18
|
-
fontFamily: item.fontFamily,
|
|
19
|
-
slug: kebabCase( item.fontFamily.toLowerCase() ),
|
|
20
|
-
fontFace: [],
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
acc[ item.fontFamily ].fontFace.push( item );
|
|
24
|
-
return acc;
|
|
25
|
-
}, {} );
|
|
26
|
-
return Object.values( fontFamiliesObject );
|
|
27
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
function findNearest( input, numbers ) {
|
|
2
|
-
// If the numbers array is empty, return null
|
|
3
|
-
if ( numbers.length === 0 ) {
|
|
4
|
-
return null;
|
|
5
|
-
}
|
|
6
|
-
// Sort the array based on the absolute difference with the input
|
|
7
|
-
numbers.sort( ( a, b ) => Math.abs( input - a ) - Math.abs( input - b ) );
|
|
8
|
-
// Return the first element (which will be the nearest) from the sorted array
|
|
9
|
-
return numbers[ 0 ];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function extractFontWeights( fontFaces ) {
|
|
13
|
-
const result = [];
|
|
14
|
-
|
|
15
|
-
fontFaces.forEach( ( face ) => {
|
|
16
|
-
const weights = String( face.fontWeight ).split( ' ' );
|
|
17
|
-
|
|
18
|
-
if ( weights.length === 2 ) {
|
|
19
|
-
const start = parseInt( weights[ 0 ] );
|
|
20
|
-
const end = parseInt( weights[ 1 ] );
|
|
21
|
-
|
|
22
|
-
for ( let i = start; i <= end; i += 100 ) {
|
|
23
|
-
result.push( i );
|
|
24
|
-
}
|
|
25
|
-
} else if ( weights.length === 1 ) {
|
|
26
|
-
result.push( parseInt( weights[ 0 ] ) );
|
|
27
|
-
}
|
|
28
|
-
} );
|
|
29
|
-
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/*
|
|
34
|
-
* Format the font family to use in the CSS font-family property of a CSS rule.
|
|
35
|
-
*
|
|
36
|
-
* The input can be a string with the font family name or a string with multiple font family names separated by commas.
|
|
37
|
-
* It follows the recommendations from the CSS Fonts Module Level 4.
|
|
38
|
-
* https://www.w3.org/TR/css-fonts-4/#font-family-prop
|
|
39
|
-
*
|
|
40
|
-
* @param {string} input - The font family.
|
|
41
|
-
* @return {string} The formatted font family.
|
|
42
|
-
*
|
|
43
|
-
* Example:
|
|
44
|
-
* formatFontFamily( "Open Sans, Font+Name, sans-serif" ) => '"Open Sans", "Font+Name", sans-serif'
|
|
45
|
-
* formatFontFamily( "'Open Sans', generic(kai), sans-serif" ) => '"Open Sans", sans-serif'
|
|
46
|
-
* formatFontFamily( "DotGothic16, Slabo 27px, serif" ) => '"DotGothic16","Slabo 27px",serif'
|
|
47
|
-
* formatFontFamily( "Mine's, Moe's Typography" ) => `"mine's","Moe's Typography"`
|
|
48
|
-
*/
|
|
49
|
-
export function formatFontFamily( input ) {
|
|
50
|
-
// Matches strings that are not exclusively alphabetic characters or hyphens, and do not exactly follow the pattern generic(alphabetic characters or hyphens).
|
|
51
|
-
const regex = /^(?!generic\([ a-zA-Z\-]+\)$)(?!^[a-zA-Z\-]+$).+/;
|
|
52
|
-
const output = input.trim();
|
|
53
|
-
|
|
54
|
-
const formatItem = ( item ) => {
|
|
55
|
-
item = item.trim();
|
|
56
|
-
if ( item.match( regex ) ) {
|
|
57
|
-
// removes leading and trailing quotes.
|
|
58
|
-
item = item.replace( /^["']|["']$/g, '' );
|
|
59
|
-
return `"${ item }"`;
|
|
60
|
-
}
|
|
61
|
-
return item;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
if ( output.includes( ',' ) ) {
|
|
65
|
-
return output
|
|
66
|
-
.split( ',' )
|
|
67
|
-
.map( formatItem )
|
|
68
|
-
.filter( ( item ) => item !== '' )
|
|
69
|
-
.join( ', ' );
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return formatItem( output );
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/*
|
|
76
|
-
* Format the font face name to use in the font-family property of a font face.
|
|
77
|
-
*
|
|
78
|
-
* The input can be a string with the font face name or a string with multiple font face names separated by commas.
|
|
79
|
-
* It removes the leading and trailing quotes from the font face name.
|
|
80
|
-
*
|
|
81
|
-
* @param {string} input - The font face name.
|
|
82
|
-
* @return {string} The formatted font face name.
|
|
83
|
-
*
|
|
84
|
-
* Example:
|
|
85
|
-
* formatFontFaceName("Open Sans") => "Open Sans"
|
|
86
|
-
* formatFontFaceName("'Open Sans', sans-serif") => "Open Sans"
|
|
87
|
-
* formatFontFaceName(", 'Open Sans', 'Helvetica Neue', sans-serif") => "Open Sans"
|
|
88
|
-
*/
|
|
89
|
-
export function formatFontFaceName( input ) {
|
|
90
|
-
if ( ! input ) {
|
|
91
|
-
return '';
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
let output = input.trim();
|
|
95
|
-
if ( output.includes( ',' ) ) {
|
|
96
|
-
output = output
|
|
97
|
-
.split( ',' )
|
|
98
|
-
// finds the first item that is not an empty string.
|
|
99
|
-
.find( ( item ) => item.trim() !== '' )
|
|
100
|
-
.trim();
|
|
101
|
-
}
|
|
102
|
-
// removes leading and trailing quotes.
|
|
103
|
-
output = output.replace( /^["']|["']$/g, '' );
|
|
104
|
-
|
|
105
|
-
// Firefox needs the font name to be wrapped in double quotes meanwhile other browsers don't.
|
|
106
|
-
if ( window.navigator.userAgent.toLowerCase().includes( 'firefox' ) ) {
|
|
107
|
-
output = `"${ output }"`;
|
|
108
|
-
}
|
|
109
|
-
return output;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function getFamilyPreviewStyle( family ) {
|
|
113
|
-
const style = { fontFamily: formatFontFamily( family.fontFamily ) };
|
|
114
|
-
|
|
115
|
-
if ( ! Array.isArray( family.fontFace ) ) {
|
|
116
|
-
style.fontWeight = '400';
|
|
117
|
-
style.fontStyle = 'normal';
|
|
118
|
-
return style;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if ( family.fontFace ) {
|
|
122
|
-
//get all the font faces with normal style
|
|
123
|
-
const normalFaces = family.fontFace.filter(
|
|
124
|
-
( face ) =>
|
|
125
|
-
face?.fontStyle && face.fontStyle.toLowerCase() === 'normal'
|
|
126
|
-
);
|
|
127
|
-
if ( normalFaces.length > 0 ) {
|
|
128
|
-
style.fontStyle = 'normal';
|
|
129
|
-
const normalWeights = extractFontWeights( normalFaces );
|
|
130
|
-
const nearestWeight = findNearest( 400, normalWeights );
|
|
131
|
-
style.fontWeight = String( nearestWeight ) || '400';
|
|
132
|
-
} else {
|
|
133
|
-
style.fontStyle =
|
|
134
|
-
( family.fontFace.length && family.fontFace[ 0 ].fontStyle ) ||
|
|
135
|
-
'normal';
|
|
136
|
-
style.fontWeight =
|
|
137
|
-
( family.fontFace.length &&
|
|
138
|
-
String( family.fontFace[ 0 ].fontWeight ) ) ||
|
|
139
|
-
'400';
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return style;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export function getFacePreviewStyle( face ) {
|
|
147
|
-
return {
|
|
148
|
-
fontFamily: formatFontFamily( face.fontFamily ),
|
|
149
|
-
fontStyle: face.fontStyle || 'normal',
|
|
150
|
-
fontWeight: face.fontWeight || '400',
|
|
151
|
-
};
|
|
152
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
function getNumericFontWeight( value ) {
|
|
2
|
-
switch ( value ) {
|
|
3
|
-
case 'normal':
|
|
4
|
-
return 400;
|
|
5
|
-
case 'bold':
|
|
6
|
-
return 700;
|
|
7
|
-
case 'bolder':
|
|
8
|
-
return 500;
|
|
9
|
-
case 'lighter':
|
|
10
|
-
return 300;
|
|
11
|
-
default:
|
|
12
|
-
return parseInt( value, 10 );
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function sortFontFaces( faces ) {
|
|
17
|
-
return faces.sort( ( a, b ) => {
|
|
18
|
-
// Ensure 'normal' fontStyle is always first
|
|
19
|
-
if ( a.fontStyle === 'normal' && b.fontStyle !== 'normal' ) {
|
|
20
|
-
return -1;
|
|
21
|
-
}
|
|
22
|
-
if ( b.fontStyle === 'normal' && a.fontStyle !== 'normal' ) {
|
|
23
|
-
return 1;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// If both fontStyles are the same, sort by fontWeight
|
|
27
|
-
if ( a.fontStyle === b.fontStyle ) {
|
|
28
|
-
return (
|
|
29
|
-
getNumericFontWeight( a.fontWeight ) -
|
|
30
|
-
getNumericFontWeight( b.fontWeight )
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Sort other fontStyles alphabetically
|
|
35
|
-
return a.fontStyle.localeCompare( b.fontStyle );
|
|
36
|
-
} );
|
|
37
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import filterFonts from '../filter-fonts';
|
|
5
|
-
|
|
6
|
-
describe( 'filterFonts', () => {
|
|
7
|
-
const mockFonts = [
|
|
8
|
-
{
|
|
9
|
-
font_family_settings: { name: 'Arial' },
|
|
10
|
-
categories: [ 'sans-serif' ],
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
font_family_settings: { name: 'Arial Condensed' },
|
|
14
|
-
categories: [ 'sans-serif' ],
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
font_family_settings: { name: 'Times New Roman' },
|
|
18
|
-
categories: [ 'serif' ],
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
font_family_settings: { name: 'Courier New' },
|
|
22
|
-
categories: [ 'monospace' ],
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
font_family_settings: { name: 'Romantic' },
|
|
26
|
-
categories: [ 'cursive' ],
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
it( 'should return all fonts if no filters are provided', () => {
|
|
31
|
-
const result = filterFonts( mockFonts, {} );
|
|
32
|
-
expect( result ).toEqual( mockFonts );
|
|
33
|
-
} );
|
|
34
|
-
|
|
35
|
-
it( 'should filter by category', () => {
|
|
36
|
-
const result = filterFonts( mockFonts, { category: 'serif' } );
|
|
37
|
-
expect( result ).toEqual( [
|
|
38
|
-
{
|
|
39
|
-
font_family_settings: { name: 'Times New Roman' },
|
|
40
|
-
categories: [ 'serif' ],
|
|
41
|
-
},
|
|
42
|
-
] );
|
|
43
|
-
} );
|
|
44
|
-
|
|
45
|
-
it( 'should return all fonts if category is "all"', () => {
|
|
46
|
-
const result = filterFonts( mockFonts, { category: 'all' } );
|
|
47
|
-
expect( result ).toEqual( mockFonts );
|
|
48
|
-
} );
|
|
49
|
-
|
|
50
|
-
it( 'should filter by search', () => {
|
|
51
|
-
const result = filterFonts( mockFonts, { search: 'ari' } );
|
|
52
|
-
expect( result ).toEqual( [
|
|
53
|
-
{
|
|
54
|
-
font_family_settings: { name: 'Arial' },
|
|
55
|
-
categories: [ 'sans-serif' ],
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
font_family_settings: { name: 'Arial Condensed' },
|
|
59
|
-
categories: [ 'sans-serif' ],
|
|
60
|
-
},
|
|
61
|
-
] );
|
|
62
|
-
} );
|
|
63
|
-
|
|
64
|
-
it( 'should be case insensitive when filtering by search', () => {
|
|
65
|
-
const result = filterFonts( mockFonts, { search: 'RoMANtic' } );
|
|
66
|
-
expect( result ).toEqual( [
|
|
67
|
-
{
|
|
68
|
-
font_family_settings: { name: 'Romantic' },
|
|
69
|
-
categories: [ 'cursive' ],
|
|
70
|
-
},
|
|
71
|
-
] );
|
|
72
|
-
} );
|
|
73
|
-
|
|
74
|
-
it( 'should filter by both category and search', () => {
|
|
75
|
-
const result = filterFonts( mockFonts, {
|
|
76
|
-
category: 'serif',
|
|
77
|
-
search: 'Times',
|
|
78
|
-
} );
|
|
79
|
-
expect( result ).toEqual( [
|
|
80
|
-
{
|
|
81
|
-
font_family_settings: { name: 'Times New Roman' },
|
|
82
|
-
categories: [ 'serif' ],
|
|
83
|
-
},
|
|
84
|
-
] );
|
|
85
|
-
} );
|
|
86
|
-
|
|
87
|
-
it( 'should return an empty array if no fonts match the filter criteria', () => {
|
|
88
|
-
const result = filterFonts( mockFonts, {
|
|
89
|
-
category: 'serif',
|
|
90
|
-
search: 'Arial',
|
|
91
|
-
} );
|
|
92
|
-
expect( result ).toEqual( [] );
|
|
93
|
-
} );
|
|
94
|
-
|
|
95
|
-
it( 'should return an empty array if fonts array is not provided', () => {
|
|
96
|
-
const result = filterFonts( undefined, { category: 'serif' } );
|
|
97
|
-
expect( result ).toEqual( [] );
|
|
98
|
-
} );
|
|
99
|
-
} );
|