From 89271c8545d0403a3acaac79c2f8ff0e9facee96 Mon Sep 17 00:00:00 2001 From: David Calhoun <github@davidcalhoun.me> Date: Tue, 4 Mar 2025 14:35:35 -0500 Subject: [PATCH 1/9] feat: Enable plugins for WPCOM sites Adjust strategy to shorten time-to-ship necessary REST API endpoints. --- .../NewGutenberg/NewGutenbergViewController.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift b/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift index 75916bcb99c4..07c120835610 100644 --- a/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift +++ b/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift @@ -123,8 +123,8 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor self.navigationBarManager = navigationBarManager ?? PostEditorNavigationBarManager() let selfHostedApiUrl = post.blog.url(withPath: "wp-json/") - let isSelfHosted = !post.blog.isHostedAtWPcom && !post.blog.isAtomic() - let siteApiRoot = post.blog.isAccessibleThroughWPCom() && !isSelfHosted ? post.blog.wordPressComRestApi()?.baseURL.absoluteString : selfHostedApiUrl + let isWPComSite = post.blog.isHostedAtWPcom || post.blog.isAtomic() + let siteApiRoot = post.blog.isAccessibleThroughWPCom() && isWPComSite ? post.blog.wordPressComRestApi()?.baseURL.absoluteString : selfHostedApiUrl let siteId = post.blog.dotComID?.stringValue let authToken = post.blog.authToken ?? "" var authHeader = "Bearer \(authToken)" @@ -154,7 +154,7 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor conf.authHeader = authHeader conf.themeStyles = FeatureFlag.newGutenbergThemeStyles.enabled - conf.plugins = FeatureFlag.newGutenbergPlugins.enabled && isSelfHosted + conf.plugins = FeatureFlag.newGutenbergPlugins.enabled && isWPComSite self.editorViewController = GutenbergKit.EditorViewController(configuration: conf) From 9e383b2907e3dd9b1cfe6c711fd5844e72cc7c98 Mon Sep 17 00:00:00 2001 From: David Calhoun <github@davidcalhoun.me> Date: Tue, 4 Mar 2025 14:36:49 -0500 Subject: [PATCH 2/9] feat: Provide all REST API namespace patterns to editor Ensures the editor can detect namespace paths regardless of which pattern is used. --- .../NewGutenberg/NewGutenbergViewController.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift b/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift index 07c120835610..4d2c3eb58d27 100644 --- a/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift +++ b/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift @@ -126,6 +126,7 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor let isWPComSite = post.blog.isHostedAtWPcom || post.blog.isAtomic() let siteApiRoot = post.blog.isAccessibleThroughWPCom() && isWPComSite ? post.blog.wordPressComRestApi()?.baseURL.absoluteString : selfHostedApiUrl let siteId = post.blog.dotComID?.stringValue + let siteDomain = post.blog.primaryDomainAddress let authToken = post.blog.authToken ?? "" var authHeader = "Bearer \(authToken)" @@ -139,7 +140,14 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor } } - let siteApiNamespace = post.blog.dotComID != nil && !isSelfHosted && applicationPassword == nil ? "sites/\(siteId ?? "")" : "" + // Must provide both namespace forms to detect usages of both forms in third-party code + var siteApiNamespace: [String] = [] + if isWPComSite { + if let siteId { + siteApiNamespace.append("sites/\(siteId)") + } + siteApiNamespace.append("sites/\(siteDomain)") + } var conf = EditorConfiguration( title: post.postTitle ?? "", From b83c90fd3a5809a7c85480cc0d0e9ada42b44cf1 Mon Sep 17 00:00:00 2001 From: David Calhoun <github@davidcalhoun.me> Date: Tue, 4 Mar 2025 14:37:45 -0500 Subject: [PATCH 3/9] feat: Provide editor namespace excluded paths Some REST APIs are site-specific and require a site namespace, others are global. --- .../ViewRelated/NewGutenberg/NewGutenbergViewController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift b/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift index 4d2c3eb58d27..3a8661e50e68 100644 --- a/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift +++ b/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift @@ -159,6 +159,7 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor conf.siteURL = post.blog.url ?? "" conf.siteApiRoot = siteApiRoot ?? "" conf.siteApiNamespace = siteApiNamespace + conf.namespaceExcludedPaths = ["/wpcom/v2/following/recommendations", "/wpcom/v2/following/mine"] conf.authHeader = authHeader conf.themeStyles = FeatureFlag.newGutenbergThemeStyles.enabled From 90bb9a2f980f18db937b4f7cd600d015f3412464 Mon Sep 17 00:00:00 2001 From: David Calhoun <github@davidcalhoun.me> Date: Fri, 7 Mar 2025 16:44:31 -0500 Subject: [PATCH 4/9] feat: Set site type global Enables Jetpack plugin blocks to accurately detect Jetpack's "connection" status. --- .../NewGutenberg/NewGutenbergViewController.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift b/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift index 3a8661e50e68..12963bcb38a2 100644 --- a/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift +++ b/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift @@ -165,6 +165,13 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor conf.themeStyles = FeatureFlag.newGutenbergThemeStyles.enabled conf.plugins = FeatureFlag.newGutenbergPlugins.enabled && isWPComSite + if !post.blog.isSelfHosted { + let siteType: String = post.blog.isHostedAtWPcom ? "simple" : "atomic" + conf.webViewGlobals = [ + WebViewGlobal(name: "_currentSiteType", value: .string(siteType)) + ] + } + self.editorViewController = GutenbergKit.EditorViewController(configuration: conf) super.init(nibName: nil, bundle: nil) From 7d64a3e7a8c3c0b8f7f71236dbb31d7ca90ebba6 Mon Sep 17 00:00:00 2001 From: David Calhoun <github@davidcalhoun.me> Date: Mon, 24 Mar 2025 16:09:18 -0400 Subject: [PATCH 5/9] feat: Expose experimental editor plugins feature --- .../Me/App Settings/ExperimentalFeaturesDataProvider.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/Classes/ViewRelated/Me/App Settings/ExperimentalFeaturesDataProvider.swift b/WordPress/Classes/ViewRelated/Me/App Settings/ExperimentalFeaturesDataProvider.swift index 3cef9c43dfaa..baebfd381ff3 100644 --- a/WordPress/Classes/ViewRelated/Me/App Settings/ExperimentalFeaturesDataProvider.swift +++ b/WordPress/Classes/ViewRelated/Me/App Settings/ExperimentalFeaturesDataProvider.swift @@ -8,6 +8,7 @@ class ExperimentalFeaturesDataProvider: ExperimentalFeaturesViewModel.DataProvid FeatureFlag.authenticateUsingApplicationPassword, FeatureFlag.newGutenberg, FeatureFlag.newGutenbergThemeStyles, + FeatureFlag.newGutenbergPlugins, ] private let flagStore = FeatureFlagOverrideStore() From 9b577c6160c1f54ec6e5981abd0466c7d7392caf Mon Sep 17 00:00:00 2001 From: David Calhoun <github@davidcalhoun.me> Date: Mon, 24 Mar 2025 16:10:16 -0400 Subject: [PATCH 6/9] feat: Limit experimental editor plugin support to WPCOM Simple sites Until we can authenticate via application passwords, Jetpack-connected sites fail to authenticate API requests originating from plugin blocks. E.g., Jetpack blocks currently make failing requests to the site domain rather than the WPCOM API. --- .../ViewRelated/NewGutenberg/NewGutenbergViewController.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift b/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift index 12963bcb38a2..791e9d9c6fd0 100644 --- a/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift +++ b/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift @@ -163,7 +163,8 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor conf.authHeader = authHeader conf.themeStyles = FeatureFlag.newGutenbergThemeStyles.enabled - conf.plugins = FeatureFlag.newGutenbergPlugins.enabled && isWPComSite + // Limited to Simple sites until application password auth is supported + conf.plugins = FeatureFlag.newGutenbergPlugins.enabled && post.blog.isHostedAtWPcom if !post.blog.isSelfHosted { let siteType: String = post.blog.isHostedAtWPcom ? "simple" : "atomic" From a6784a753527dc8118d0ddd4ff2f451fcbe5c662 Mon Sep 17 00:00:00 2001 From: David Calhoun <github@davidcalhoun.me> Date: Tue, 25 Mar 2025 17:05:19 -0400 Subject: [PATCH 7/9] build: Update GutenbergKit ref --- Modules/Package.swift | 2 +- WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Package.swift b/Modules/Package.swift index e31e80a5a80b..dce404c6ca00 100644 --- a/Modules/Package.swift +++ b/Modules/Package.swift @@ -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-20250127"), - .package(url: "https://github.com/wordpress-mobile/GutenbergKit", revision: "947c5315198eea96e3e8c32fcc6afa59ef242638"), + .package(url: "https://github.com/wordpress-mobile/GutenbergKit", revision: "11b9c2ec7d75bb68dcdebeff0ffe6034a7784544"), .package(url: "https://github.com/Automattic/color-studio", branch: "trunk"), .package(url: "https://github.com/wordpress-mobile/AztecEditor-iOS", from: "1.20.0"), ], diff --git a/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved b/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved index 9b9551386cf0..87cfec2f788e 100644 --- a/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "b048f2348f14b6f12b4a4b8588355abe499af3f8f4e91cacc054e98187a7746c", + "originHash" : "30d28689f1ff892c21d4ac727128fc2287c04c6efc8f821e677c057bbfd820c5", "pins" : [ { "identity" : "alamofire", @@ -150,7 +150,7 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/wordpress-mobile/GutenbergKit", "state" : { - "revision" : "947c5315198eea96e3e8c32fcc6afa59ef242638" + "revision" : "11b9c2ec7d75bb68dcdebeff0ffe6034a7784544" } }, { From f916dcb31ecdabaab62fc14133c9ef21fe6b1a3c Mon Sep 17 00:00:00 2001 From: David Calhoun <github@davidcalhoun.me> Date: Tue, 25 Mar 2025 20:02:59 -0400 Subject: [PATCH 8/9] build: Update GutenbergKit ref --- Modules/Package.swift | 2 +- WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Package.swift b/Modules/Package.swift index dce404c6ca00..292d4fdabbac 100644 --- a/Modules/Package.swift +++ b/Modules/Package.swift @@ -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-20250127"), - .package(url: "https://github.com/wordpress-mobile/GutenbergKit", revision: "11b9c2ec7d75bb68dcdebeff0ffe6034a7784544"), + .package(url: "https://github.com/wordpress-mobile/GutenbergKit", revision: "74bc5eefe939632d3087ff408944ec23d5d780b2"), .package(url: "https://github.com/Automattic/color-studio", branch: "trunk"), .package(url: "https://github.com/wordpress-mobile/AztecEditor-iOS", from: "1.20.0"), ], diff --git a/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved b/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved index 87cfec2f788e..e7a6a31d9e9d 100644 --- a/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "30d28689f1ff892c21d4ac727128fc2287c04c6efc8f821e677c057bbfd820c5", + "originHash" : "5d2f0bd0f46ebc30565c1b6c7b47c171f924f35aaa919d4b781e2f45b353ae51", "pins" : [ { "identity" : "alamofire", @@ -150,7 +150,7 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/wordpress-mobile/GutenbergKit", "state" : { - "revision" : "11b9c2ec7d75bb68dcdebeff0ffe6034a7784544" + "revision" : "74bc5eefe939632d3087ff408944ec23d5d780b2" } }, { From fb06ad7db694ab0791302f80759b9a07cce66408 Mon Sep 17 00:00:00 2001 From: David Calhoun <github@davidcalhoun.me> Date: Tue, 25 Mar 2025 21:11:43 -0400 Subject: [PATCH 9/9] feat: Control GutenbergKit plugin support availability Allow remotely disabling this experimental feature while the API endpoint is deployed or during a breakage. --- .../Utility/BuildInformation/RemoteFeatureFlag.swift | 7 +++++++ .../Me/App Settings/ExperimentalFeaturesDataProvider.swift | 3 +-- .../NewGutenberg/NewGutenbergViewController.swift | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/WordPress/Classes/Utility/BuildInformation/RemoteFeatureFlag.swift b/WordPress/Classes/Utility/BuildInformation/RemoteFeatureFlag.swift index 1fe3dbbe8e9d..90176c62d67b 100644 --- a/WordPress/Classes/Utility/BuildInformation/RemoteFeatureFlag.swift +++ b/WordPress/Classes/Utility/BuildInformation/RemoteFeatureFlag.swift @@ -29,6 +29,7 @@ enum RemoteFeatureFlag: Int, CaseIterable { case inAppUpdates case gravatarQuickEditor case dotComWebLogin + case newGutenbergPluginsAvailability var defaultValue: Bool { switch self { @@ -86,6 +87,8 @@ enum RemoteFeatureFlag: Int, CaseIterable { return BuildConfiguration.current ~= [.localDeveloper, .a8cBranchTest, .a8cPrereleaseTesting] case .dotComWebLogin: return false + case .newGutenbergPluginsAvailability: + return false } } @@ -146,6 +149,8 @@ enum RemoteFeatureFlag: Int, CaseIterable { return "gravatar_quick_editor" case .dotComWebLogin: return "jp_wpcom_web_login" + case .newGutenbergPluginsAvailability: + return "new_gutenberg_plugins_availability" } } @@ -205,6 +210,8 @@ enum RemoteFeatureFlag: Int, CaseIterable { return "Gravatar Quick Editor" case .dotComWebLogin: return "Log in to WordPress.com from web browser" + case .newGutenbergPluginsAvailability: + return "Experimental Block Editor Plugins Availability" } } diff --git a/WordPress/Classes/ViewRelated/Me/App Settings/ExperimentalFeaturesDataProvider.swift b/WordPress/Classes/ViewRelated/Me/App Settings/ExperimentalFeaturesDataProvider.swift index baebfd381ff3..053282bc00f7 100644 --- a/WordPress/Classes/ViewRelated/Me/App Settings/ExperimentalFeaturesDataProvider.swift +++ b/WordPress/Classes/ViewRelated/Me/App Settings/ExperimentalFeaturesDataProvider.swift @@ -8,8 +8,7 @@ class ExperimentalFeaturesDataProvider: ExperimentalFeaturesViewModel.DataProvid FeatureFlag.authenticateUsingApplicationPassword, FeatureFlag.newGutenberg, FeatureFlag.newGutenbergThemeStyles, - FeatureFlag.newGutenbergPlugins, - ] + ] + (RemoteFeatureFlag.newGutenbergPluginsAvailability.enabled() ? [FeatureFlag.newGutenbergPlugins] : []) private let flagStore = FeatureFlagOverrideStore() diff --git a/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift b/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift index 791e9d9c6fd0..cd0d3682f85e 100644 --- a/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift +++ b/WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift @@ -164,7 +164,7 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor conf.themeStyles = FeatureFlag.newGutenbergThemeStyles.enabled // Limited to Simple sites until application password auth is supported - conf.plugins = FeatureFlag.newGutenbergPlugins.enabled && post.blog.isHostedAtWPcom + conf.plugins = FeatureFlag.newGutenbergPlugins.enabled && RemoteFeatureFlag.newGutenbergPluginsAvailability.enabled() && post.blog.isHostedAtWPcom if !post.blog.isSelfHosted { let siteType: String = post.blog.isHostedAtWPcom ? "simple" : "atomic"