@@ -41,8 +41,10 @@ struct AppRootView: View {
4141 . onChange ( of: self . selectedConfiguration) { oldValue, newValue in
4242 switch newValue {
4343 case . bundledEditor:
44- let config = createBundledConfiguration ( )
45- activeEditorConfiguration = config
44+ activeEditorConfiguration = EditorConfiguration . bundled
45+ . toBuilder ( )
46+ . setNativeInserterEnabled ( self . isNativeInserterEnabled)
47+ . build ( )
4648 case . editorConfiguration( let config) :
4749 self . loadEditorConfiguration ( for: config)
4850 case . none:
@@ -65,9 +67,10 @@ struct AppRootView: View {
6567 private func loadEditorConfiguration( for config: ConfiguredEditor ) {
6668 Task {
6769 do {
70+ let parsedApiRoot = try ParsedUrl . parse ( input: config. siteApiRoot)
6871 let client = WordPressAPI (
6972 urlSession: . shared,
70- apiRootUrl: try ParsedUrl . parse ( input : config . siteApiRoot ) ,
73+ apiRootUrl: parsedApiRoot ,
7174 authentication: . authorizationHeader( token: config. authHeader)
7275 )
7376
@@ -76,16 +79,18 @@ struct AppRootView: View {
7679 let canUsePlugins = apiRoot. hasRoute ( route: " /wpcom/v2/editor-assets " )
7780 let canUseEditorStyles = apiRoot. hasRoute ( route: " /wp-block-editor/v1/settings " )
7881
79- self . activeEditorConfiguration = EditorConfigurationBuilder ( )
80- . setShouldUseThemeStyles ( canUseEditorStyles)
81- . setShouldUsePlugins ( canUsePlugins)
82- . setSiteUrl ( config. siteUrl)
83- . setSiteApiRoot ( config. siteApiRoot)
84- . setAuthHeader ( config. authHeader)
85- . setNativeInserterEnabled ( isNativeInserterEnabled)
86- . setLogLevel ( . debug)
87- . setEnableNetworkLogging ( true )
88- . build ( )
82+ self . activeEditorConfiguration = EditorConfigurationBuilder (
83+ postType: " post " ,
84+ siteURL: URL ( string: apiRoot. siteUrlString ( ) ) !,
85+ siteApiRoot: parsedApiRoot. asURL ( )
86+ )
87+ . setShouldUseThemeStyles ( canUseEditorStyles)
88+ . setShouldUsePlugins ( canUsePlugins)
89+ . setAuthHeader ( config. authHeader)
90+ . setNativeInserterEnabled ( isNativeInserterEnabled)
91+ . setLogLevel ( . debug)
92+ . setEnableNetworkLogging ( true )
93+ . build ( )
8994 } catch {
9095 self . hasError = true
9196 self . error = AppError ( errorDescription: error. localizedDescription)
@@ -97,17 +102,6 @@ struct AppRootView: View {
97102 configurations. removeAll { $0. id == config. id }
98103 configurationStorage. saveConfigurations ( configurations)
99104 }
100-
101- private func createBundledConfiguration( ) -> EditorConfiguration {
102- EditorConfigurationBuilder ( )
103- . setShouldUsePlugins ( false )
104- . setSiteUrl ( " " )
105- . setSiteApiRoot ( " " )
106- . setAuthHeader ( " " )
107- . setNativeInserterEnabled ( isNativeInserterEnabled)
108- . setEnableNetworkLogging ( true )
109- . build ( )
110- }
111105}
112106
113107struct AppError : LocalizedError {
0 commit comments