Skip to content

Commit ef25832

Browse files
authored
Remove title field from comment composer (#24089)
* Update GutenbergKit * Install from trunk
1 parent bdb2563 commit ef25832

File tree

4 files changed

+22
-51
lines changed

4 files changed

+22
-51
lines changed

Modules/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let package = Package(
4848
.package(url: "https://github.com/zendesk/support_sdk_ios", from: "8.0.3"),
4949
// We can't use wordpress-rs branches nor commits here. Only tags work.
5050
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20250127"),
51-
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", from: "0.0.5"),
51+
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "trunk"),
5252
.package(url: "https://github.com/Automattic/color-studio", branch: "trunk"),
5353
.package(url: "https://github.com/wordpress-mobile/AztecEditor-iOS", from: "1.20.0"),
5454
],

WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WordPress/Classes/ViewRelated/Comments/Controllers/Composer/CommentGutenbergEditorViewController.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ final class CommentGutenbergEditorViewController: UIViewController, CommentEdito
4444
override func viewDidLoad() {
4545
super.viewDidLoad()
4646

47-
let editorVC = GutenbergKit.EditorViewController(
48-
content: initialContent ?? "",
49-
service: EditorService(client: EmptyNetworkClient())
50-
)
47+
var configuration = EditorConfiguration(content: initialContent ?? "")
48+
configuration.hideTitle = true
49+
50+
let editorVC = GutenbergKit.EditorViewController(configuration: configuration)
5151
editorVC.delegate = self
5252

5353
view.addSubview(editorVC.view)
@@ -105,9 +105,3 @@ extension CommentGutenbergEditorViewController: GutenbergKit.EditorViewControlle
105105
// Do nothing
106106
}
107107
}
108-
109-
private final class EmptyNetworkClient: GutenbergKit.EditorNetworkingClient {
110-
func send(_ request: EditorNetworkRequest) async throws -> EditorNetworkResponse {
111-
throw URLError(.unknown)
112-
}
113-
}

WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor
120120
self.editorSession = PostEditorAnalyticsSession(editor: .gutenbergKit, post: post)
121121
self.navigationBarManager = navigationBarManager ?? PostEditorNavigationBarManager()
122122

123-
let networkClient = NewGutenbergNetworkClient(blog: post.blog)
124-
125123
let selfHostedApiUrl = post.blog.url(withPath: "wp-json/")
126124
let isSelfHosted = !post.blog.isHostedAtWPcom && !post.blog.isAtomic()
127125
let siteApiRoot = post.blog.isAccessibleThroughWPCom() && !isSelfHosted ? post.blog.wordPressComRestApi()?.baseURL.absoluteString : selfHostedApiUrl
@@ -140,22 +138,23 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor
140138
}
141139

142140
let siteApiNamespace = post.blog.dotComID != nil && !isSelfHosted && applicationPassword == nil ? "sites/\(siteId ?? "")" : ""
143-
let postType = post is Page ? "page" : "post"
144-
let postId: Int? = post.postID?.intValue != -1 ? post.postID?.intValue : nil
145141

146-
self.editorViewController = GutenbergKit.EditorViewController(
147-
id: postId,
148-
type: postType,
142+
var conf = EditorConfiguration(
149143
title: post.postTitle ?? "",
150-
content: post.content ?? "",
151-
service: GutenbergKit.EditorService(client: networkClient),
152-
themeStyles: FeatureFlag.newGutenbergThemeStyles.enabled,
153-
plugins: FeatureFlag.newGutenbergPlugins.enabled && isSelfHosted,
154-
siteURL: post.blog.url ?? "",
155-
siteApiRoot: siteApiRoot!,
156-
siteApiNamespace: siteApiNamespace,
157-
authHeader: authHeader
144+
content: post.content ?? ""
158145
)
146+
conf.postID = post.postID?.intValue != -1 ? post.postID?.intValue : nil
147+
conf.postType = post is Page ? "page" : "post"
148+
149+
conf.siteURL = post.blog.url ?? ""
150+
conf.siteApiRoot = siteApiRoot ?? ""
151+
conf.siteApiNamespace = siteApiNamespace
152+
conf.authHeader = authHeader
153+
154+
conf.themeStyles = FeatureFlag.newGutenbergThemeStyles.enabled
155+
conf.plugins = FeatureFlag.newGutenbergPlugins.enabled && isSelfHosted
156+
157+
self.editorViewController = GutenbergKit.EditorViewController(configuration: conf)
159158

160159
super.init(nibName: nil, bundle: nil)
161160

@@ -415,28 +414,6 @@ extension NewGutenbergViewController: GutenbergKit.EditorViewControllerDelegate
415414
}
416415
}
417416

418-
private struct NewGutenbergNetworkClient: GutenbergKit.EditorNetworkingClient {
419-
private let api: WordPressOrgRestApi?
420-
421-
init(blog: Blog) {
422-
self.api = WordPressOrgRestApi(blog: blog)
423-
}
424-
425-
func send(_ request: GutenbergKit.EditorNetworkRequest) async throws -> GutenbergKit.EditorNetworkResponse {
426-
guard let api else {
427-
throw URLError(.unknown) // Should never happen
428-
}
429-
// TODO: Add support for other requests
430-
var path = request.url.absoluteString
431-
guard path.hasPrefix("./wp-json") else {
432-
throw URLError(.unknown) // Currently unsupported
433-
}
434-
path.removePrefix("./wp-json")
435-
436-
throw URLError(.unknown) // Should never happen
437-
}
438-
}
439-
440417
// MARK: - GutenbergBridgeDelegate
441418

442419
extension NewGutenbergViewController {

0 commit comments

Comments
 (0)