Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/**
* External dependencies
* WordPress dependencies
*/
import { paramCase as kebabCase } from 'change-case';
import { privateApis as componentsPrivateApis } from '@wordpress/components';

/**
* Internal dependencies
*/
import { FONT_WEIGHTS, FONT_STYLES } from './constants';
import { unlock } from '../../../../lock-unlock';

export function setUIValuesNeeded( font, extraValues = {} ) {
if ( ! font.name && ( font.fontFamily || font.slug ) ) {
Expand Down Expand Up @@ -129,20 +130,11 @@ export function getDisplaySrcFromFontFace( input, urlPrefix ) {
return src;
}

// This function replicates one behavior of _wp_to_kebab_case().
// Additional context: https://github.com/WordPress/gutenberg/issues/53695
export function wpKebabCase( str ) {
// If a string contains a digit followed by a number, insert a dash between them.
return kebabCase( str ).replace(
/([a-zA-Z])(\d)|(\d)([a-zA-Z])/g,
'$1$3-$2$4'
);
}

export function makeFormDataFromFontFamilies( fontFamilies ) {
const formData = new FormData();
const newFontFamilies = fontFamilies.map( ( family, familyIndex ) => {
family.slug = wpKebabCase( family.slug );
const { kebabCase } = unlock( componentsPrivateApis );
family.slug = kebabCase( family.slug );
if ( family?.fontFace ) {
family.fontFace = family.fontFace.map( ( face, faceIndex ) => {
if ( face.file ) {
Expand Down

This file was deleted.