-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Global Styles] Implement Global Styles endpoint (#16411)
* Update Editor Theme to pull from WordPressKit Instead. * Add Support For Global Styles endpoint * Add New Data model changes for raw GSS settings * Parse GSS setting and update Gutenberg event names * Update App for BlockEditor Settings API Changes * Fix test error * Fix Remaining test errors * Update Gutenberg ref * Update native app for editor settings endpoint changes * Update Gutenberg ref * Store and Sort the colors and gradients based on the API order * Migrate Core Data changes to 126 and re-add rawFeatures * Update Gutenberg ref * Update Gutenberg ref * Updates Gutenberg reference * Bump WPKit ref * Add WP version check to enabling GSS * Update WP Version checks and tests * Update Gutenberg Reference * Bump WordPressKit Version Co-authored-by: Gerardo Pacheco <[email protected]> Co-authored-by: Antonis Lilis <[email protected]>
- Loading branch information
3 people
authored
Jul 1, 2021
1 parent
c5ef423
commit 7225dbd
Showing
21 changed files
with
2,992 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
WordPress/Classes/Models/BlockEditorSettings+GutenbergEditorSettings.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import Foundation | ||
import WordPressKit | ||
import Gutenberg | ||
|
||
extension BlockEditorSettings: GutenbergEditorSettings { | ||
public var colors: [[String: String]]? { | ||
elementsByType(.color) | ||
} | ||
|
||
public var gradients: [[String: String]]? { | ||
elementsByType(.gradient) | ||
} | ||
|
||
private func elementsByType(_ type: BlockEditorSettingElementTypes) -> [[String: String]]? { | ||
return elements?.sorted(by: { (lhs, rhs) -> Bool in | ||
return lhs.order >= rhs.order | ||
}).compactMap({ (element) -> [String: String]? in | ||
guard element.type == type.rawValue else { return nil } | ||
return element.rawRepresentation | ||
}) | ||
} | ||
} | ||
|
||
extension BlockEditorSettings { | ||
convenience init?(editorTheme: RemoteEditorTheme, context: NSManagedObjectContext) { | ||
self.init(context: context) | ||
self.isFSETheme = false | ||
self.lastUpdated = Date() | ||
self.checksum = editorTheme.checksum | ||
|
||
var parsedElements = Set<BlockEditorSettingElement>() | ||
if let themeSupport = editorTheme.themeSupport { | ||
themeSupport.colors?.enumerated().forEach({ (index, color) in | ||
parsedElements.insert(BlockEditorSettingElement(fromRawRepresentation: color, type: .color, order: index, context: context)) | ||
}) | ||
|
||
themeSupport.gradients?.enumerated().forEach({ (index, gradient) in | ||
parsedElements.insert(BlockEditorSettingElement(fromRawRepresentation: gradient, type: .gradient, order: index, context: context)) | ||
}) | ||
} | ||
|
||
self.elements = parsedElements | ||
} | ||
|
||
convenience init?(remoteSettings: RemoteBlockEditorSettings, context: NSManagedObjectContext) { | ||
self.init(context: context) | ||
self.isFSETheme = remoteSettings.isFSETheme | ||
self.lastUpdated = Date() | ||
self.checksum = remoteSettings.checksum | ||
self.rawStyles = remoteSettings.rawStyles | ||
self.rawFeatures = remoteSettings.rawFeatures | ||
|
||
var parsedElements = Set<BlockEditorSettingElement>() | ||
|
||
remoteSettings.colors?.enumerated().forEach({ (index, color) in | ||
parsedElements.insert(BlockEditorSettingElement(fromRawRepresentation: color, type: .color, order: index, context: context)) | ||
}) | ||
|
||
remoteSettings.gradients?.enumerated().forEach({ (index, gradient) in | ||
parsedElements.insert(BlockEditorSettingElement(fromRawRepresentation: gradient, type: .gradient, order: index, context: context)) | ||
}) | ||
|
||
self.elements = parsedElements | ||
} | ||
} |
40 changes: 0 additions & 40 deletions
40
WordPress/Classes/Models/BlockEditorSettings+GutenbergEditorTheme.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.