-
Notifications
You must be signed in to change notification settings - Fork 1.1k
refactor: Use GutenbergKit configuration builder #24662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
Generated by 🚫 Danger |
// 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() |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
e5c172c
to
125229e
Compare
Adopt the latest patterns to embrace immutable configuration.
125229e
to
518ebe3
Compare
|
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.