Skip to content

Commit

Permalink
feat: GutenbergKit history navigation (#23961)
Browse files Browse the repository at this point in the history
* feat: Reinstate site icon within navigation bar back button

This was temporarily removed due to a separate refactor of the site icon
view.

* feat: Toggle undo/redo button state alongside editor state

Allow button interactivity when undo/redo actions are available.

* feat: Navigate editor history

Enable stepping forwards and backwards through the editor history.

* build: Update GutenbergKit ref

* build: Update GutenbergKit ref

* docs: Add release note

* build: Update GutenbergKit ref
  • Loading branch information
dcalhoun authored Jan 9, 2025
1 parent 63b0f42 commit 388dbb1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Modules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let package = Package(
.package(url: "https://github.com/zendesk/support_sdk_ios", from: "8.0.3"),
// We can't use wordpress-rs branches nor commits here. Only tags work.
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20241116"),
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", revision: "4476d597b271778d001a26c50d74e527b54ebfef"),
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", revision: "5a43a1b8ab5034e5be4b4eb93c30885cc41227b2"),
.package(url: "https://github.com/Automattic/color-studio", branch: "trunk"),
],
targets: XcodeSupport.targets + [
Expand Down
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
25.7
-----
* [**] Enable history navigation (undo and redo) for the experimental editor. [#23961]

25.6
-----
Expand Down
4 changes: 2 additions & 2 deletions WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "8a87409582dec4bc7c7f6ee5d6a6761cead545bd116f82237fc9e6a881e7c3fb",
"originHash" : "4cacb81eb20e7d20d1b25f261d9303a24f725104ed3b36743fc2707b7473a93d",
"pins" : [
{
"identity" : "alamofire",
Expand Down Expand Up @@ -150,7 +150,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/wordpress-mobile/GutenbergKit",
"state" : {
"revision" : "4476d597b271778d001a26c50d74e527b54ebfef"
"revision" : "5a43a1b8ab5034e5be4b4eb93c30885cc41227b2"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,8 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor
}

private func reloadBlogIconView() {
let blog = post.blog

// if blog.hasIcon == true {
// let size = CGSize(width: 24, height: 24)
// navigationBarManager.siteIconView.imageView.downloadSiteIcon(for: blog, imageSize: size)
// } else if blog.isWPForTeams() {
// navigationBarManager.siteIconView.imageView.tintColor = UIColor.secondaryLabel
// navigationBarManager.siteIconView.imageView.image = UIImage.gridicon(.p2)
// } else {
// navigationBarManager.siteIconView.imageView.image = UIImage.siteIconPlaceholder
// }

// TODO: implement
// Docs: https://wordpress.org/gutenberg-framework/docs/basic-concepts/undo-redo
navigationBarManager.undoButton.isHidden = true
navigationBarManager.redoButton.isHidden = true
let viewModel = SiteIconViewModel(blog: post.blog, size: .small)
navigationBarManager.siteIconView.imageView.setIcon(with: viewModel)
}

// TODO: this should not be called on viewDidLoad
Expand Down Expand Up @@ -346,6 +332,11 @@ extension NewGutenbergViewController: GutenbergKit.EditorViewControllerDelegate
}
}

func editor(_ viewController: GutenbergKit.EditorViewController, didUpdateHistoryState state: GutenbergKit.EditorState) {
gutenbergDidRequestToggleRedoButton(!state.hasRedo)
gutenbergDidRequestToggleUndoButton(!state.hasUndo)
}

func editor(_ viewController: GutenbergKit.EditorViewController, performRequest: GutenbergKit.EditorNetworkRequest) async throws -> GutenbergKit.EditorNetworkResponse {
throw URLError(.unknown)
}
Expand Down Expand Up @@ -619,13 +610,11 @@ extension NewGutenbergViewController: PostEditorNavigationBarManagerDelegate {
}

func navigationBarManager(_ manager: PostEditorNavigationBarManager, undoWasPressed sender: UIButton) {
// TODO: reimplement
// self.gutenberg.onUndoPressed()
editorViewController.undo()
}

func navigationBarManager(_ manager: PostEditorNavigationBarManager, redoWasPressed sender: UIButton) {
// TODO: reimplement
// self.gutenberg.onRedoPressed()
editorViewController.redo()
}

func navigationBarManager(_ manager: PostEditorNavigationBarManager, moreWasPressed sender: UIButton) {
Expand Down

0 comments on commit 388dbb1

Please sign in to comment.