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