Skip to content

Commit 685ab36

Browse files
committed
Change editorSettings to a String
The host app doesn’t need to parse it, so we can pass the raw settings
1 parent 87ca914 commit 685ab36

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

ios/Sources/GutenbergKit/Sources/EditorConfiguration.swift

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public struct EditorConfiguration {
2727
/// Authorization header
2828
public let authHeader: String
2929
/// Raw block editor settings from the WordPress REST API
30-
public let editorSettings: EditorSettings
30+
public let editorSettings: String
3131
/// Locale used for translations
3232
public let locale: String
3333
/// Endpoint for loading editor assets, used when enabling `shouldUsePlugins`
@@ -50,7 +50,7 @@ public struct EditorConfiguration {
5050
siteApiNamespace: [String],
5151
namespaceExcludedPaths: [String],
5252
authHeader: String,
53-
editorSettings: EditorSettings,
53+
editorSettings: String,
5454
locale: String,
5555
editorAssetsEndpoint: URL? = nil,
5656
cookies: [HTTPCookie] = []
@@ -101,12 +101,6 @@ public struct EditorConfiguration {
101101
content.addingPercentEncoding(withAllowedCharacters: .alphanumerics)!
102102
}
103103

104-
var editorSettingsJSON: String {
105-
// `editorSettings` values are always `encodable` so this should never fail
106-
let jsonData = try! JSONSerialization.data(withJSONObject: editorSettings, options: [])
107-
return String(data: jsonData, encoding: .utf8) ?? "undefined"
108-
}
109-
110104
public static let `default` = EditorConfigurationBuilder().build()
111105
}
112106

@@ -123,7 +117,7 @@ public struct EditorConfigurationBuilder {
123117
private var siteApiNamespace: [String]
124118
private var namespaceExcludedPaths: [String]
125119
private var authHeader: String
126-
private var editorSettings: EditorSettings
120+
private var editorSettings: String
127121
private var locale: String
128122
private var editorAssetsEndpoint: URL?
129123

@@ -140,7 +134,7 @@ public struct EditorConfigurationBuilder {
140134
siteApiNamespace: [String] = [],
141135
namespaceExcludedPaths: [String] = [],
142136
authHeader: String = "",
143-
editorSettings: EditorSettings = [:],
137+
editorSettings: String = "undefined",
144138
locale: String = "en",
145139
editorAssetsEndpoint: URL? = nil
146140
){
@@ -233,7 +227,7 @@ public struct EditorConfigurationBuilder {
233227
return copy
234228
}
235229

236-
public func setEditorSettings(_ editorSettings: EditorSettings) -> EditorConfigurationBuilder {
230+
public func setEditorSettings(_ editorSettings: String) -> EditorConfigurationBuilder {
237231
var copy = self
238232
copy.editorSettings = editorSettings
239233
return copy

0 commit comments

Comments
 (0)