Skip to content

Commit

Permalink
Merge pull request #2904 from wordpress-mobile/fix/removeFontFamilies…
Browse files Browse the repository at this point in the history
…FromStoredTheme

Removes font families from the stored block settings response
  • Loading branch information
Antonis Lilis authored Nov 23, 2023
2 parents da7285c + cf398d5 commit b61e04f
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ data class EditorTheme(
blockEditorSettings.gradients,
null,
blockEditorSettings.styles?.toString(),
blockEditorSettings.features?.toString(),
blockEditorSettings.featuresFiltered?.toString(),
blockEditorSettings.isBlockBasedTheme,
blockEditorSettings.galleryWithImageBlocks,
blockEditorSettings.quoteBlockV2,
Expand Down Expand Up @@ -83,7 +83,25 @@ data class BlockEditorSettings(
@SerializedName("__experimentalFeatures") val features: JsonElement?,
@JsonAdapter(EditorThemeElementListSerializer::class) val colors: List<EditorThemeElement>?,
@JsonAdapter(EditorThemeElementListSerializer::class) val gradients: List<EditorThemeElement>?
)
) {
val featuresFiltered: JsonElement?
get() = features?.removeFontFamilies()

private fun JsonElement.removeFontFamilies(): JsonElement {
if (isJsonObject && asJsonObject.has("typography")) {
val featuresObject = asJsonObject
val typography = featuresObject.get("typography")
if (typography.isJsonObject) {
val typographyObject = typography.asJsonObject
if (typographyObject.has("fontFamilies")) {
typographyObject.remove("fontFamilies")
return featuresObject
}
}
}
return this
}
}

data class EditorThemeSupport(
@JsonAdapter(EditorThemeElementListSerializer::class)
Expand Down

0 comments on commit b61e04f

Please sign in to comment.