Skip to content

Conversation

dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Jul 9, 2025

Description

Adopt the latest patterns for embracing immutable configuration introduced in wordpress-mobile/GutenbergKit#146.

Testing instructions

Smoke test editor functionality dependent upon configuration—theme styles, media uploads, remote editor (plugins), etc.

@dcalhoun dcalhoun added [Type] Task Gutenberg Editing and display of Gutenberg blocks. labels Jul 9, 2025
@dangermattic
Copy link
Collaborator

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

Comment on lines +335 to +376
// TODO: `setEditorSettings` throws due to incompatibility between `[String: Any]`
// and `[String: Encodable]`. The latter is now expected by
// `GutenbergKitConfiguration.EditorSettings`. How should we reconcile this?
let updatedConfig = self.editorViewController.configuration.toBuilder()
.setEditorSettings(settings)
.build()
Copy link
Member Author

@dcalhoun dcalhoun Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crazytonyli would you please help me determine a reasonable approach for managing type safety of fetching editor settings from the API endpoint and passing it to GutenbergKit?

GutenbergKit was updated in wordpress-mobile/GutenbergKit#146 to now expect [String: Encodable] rather than [String: Any]. This seems like a sound change, but my lack of Swift experience inhibits me from determining an appropriate solution for the logic here in WP-iOS.

Please feel free to push directly to this branch if that is easiest. Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed this ping.

I gave it a go locally. Unfortunately, the settings: [String: Any] dictionary, which is returned by JSONSerialization, is not actually [String: Encodable], because the settings may contain NSNumber values, which do not conform to Encodable. So, we can't simply cast settings into [String: Encodable].

I wonder if you can change the editorSettings in GBK to be something like editorSettingsJSON: String, considering that's the value going into the web view. That'd also save the encoding and decoding round trips, which are not really necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. Thank you for explaining the foundational problem of attempting to conform to Encodable. That explains my struggles to identify proper logic for casting these types.

Your idea of simply storing and passing a JSON string makes sense. I'll explore that.

@dcalhoun dcalhoun force-pushed the refactor/use-gutenberg-kit-configuration-builder branch from e5c172c to 125229e Compare August 5, 2025 13:22
Adopt the latest patterns to embrace immutable configuration.
@dcalhoun dcalhoun force-pushed the refactor/use-gutenberg-kit-configuration-builder branch from 125229e to 518ebe3 Compare August 5, 2025 13:25
Copy link

sonarqubecloud bot commented Aug 5, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Editing and display of Gutenberg blocks. [Type] Task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants