-
Notifications
You must be signed in to change notification settings - Fork 3
Add support for Editor Settings #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
17e0732 to
4f0d2e8
Compare
| /// let safeName = url.safeFilename | ||
| /// // Result: "https---example.com-path-query-1" | ||
| /// ``` | ||
| var safeFilename: String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could just replace it with sha256 as the folder name is only needed for technical purposes. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, hashing is likely sufficient for this purpose.
A readable name might make debugging easier, but that'd likely be infrequent and manageable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also leaning towards hashing. It's simpler and more robust.
4f0d2e8 to
5ef6674
Compare
|
Oh, actually, I'll call |
dcalhoun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
I suppose we could consider adding a Use theme styles toggle beneath the Native Inserter toggle, if helpful.
| do { | ||
| try await service.setup(&updatedConfiguration) | ||
| } catch { | ||
| print("Failed to setup editor environment, confinuing with the default or cached configuration:", error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| print("Failed to setup editor environment, confinuing with the default or cached configuration:", error) | |
| print("Failed to set up editor environment, continuing with the default or cached configuration:", error) |
| /// let safeName = url.safeFilename | ||
| /// // Result: "https---example.com-path-query-1" | ||
| /// ``` | ||
| var safeFilename: String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, hashing is likely sufficient for this purpose.
A readable name might make debugging easier, but that'd likely be infrequent and manageable.
| self.authHeader = authHeader | ||
| self.urlSession = urlSession | ||
|
|
||
| self.storeURL = URL.documentsDirectory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go into "Application" not "Documents".
Good idea. It's a bit difficult due to how it's currently structured. I'll add a note to add it after other changes are done. |
Co-authored-by: David Calhoun <github@davidcalhoun.me>
What?
The demo app will now honor site's block editor settings (
wp-block-editor/v1/settings).Why?
The idea is to use the newly introduced
EditorServiceto manage the initial load and subsequent refresh of all resources required to launch the editor: editor settings and assets.In the future PRs, I plan to simplify the code in
EditorAssetsLibraryand move it toEditorService. It will fetch the manifest and the assets before "starting" the editor and will inject the preprocessed manifest using the configuration. This will give the host app control over when and how the assets are loaded and stored. With the new implementation, the requests will run in parallel, cutting the first load time by around 900ms (due to parallelization alone).I will then generate the Android implementation based on the Swift code.
How?
The new
EditorServiceprovides two simply APIs for the host app.The
setupmethod is what you call to configure the editor. On first load, it will fetch the required resources (blocking operation). On the subsequent loads, it will simply use the previously loaded data (changes infrequently). It's up to the app how to handle errors.The host app will also be responsible for calling
refreshto update the previously fetched resources (or load the initial ones). It's safe to callrefreshmultiple times as it will attach to the existing task if present. It's up to the app how to handle errors.Testing Instructions
Add a new "remote" editor and verify that the styles are applied.
Screenshots or screencast
Before / After
