-
Notifications
You must be signed in to change notification settings - Fork 3
Add native block inserter #162
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
Open
kean
wants to merge
6
commits into
trunk
Choose a base branch
from
task/native-block-inserter
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
df22734
Add native block inserter
kean 1dac78c
Disable by default
kean 8e6cbc1
Show the media strip above the first category
kean 80d00b3
Dont show Text category section title
kean 5572c4a
Refactor
kean 9ea27fc
Update scheme
kean File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -7,20 +7,48 @@ struct ContentView: View { | |
|
||
let remoteEditorConfigurations: [EditorConfiguration] = [.template] | ||
|
||
@State private var isShowingDefaultEditor = false | ||
|
||
// Configuration settings | ||
@AppStorage("enableNativeBlockInserter") private var enableNativeBlockInserter = true | ||
@AppStorage("enablePlugins") private var enablePlugins = false | ||
@AppStorage("hideTitle") private var hideTitle = false | ||
@AppStorage("autoFocusOnLoad") private var autoFocusOnLoad = true | ||
@AppStorage("themeStyles") private var themeStyles = true | ||
|
||
var body: some View { | ||
List { | ||
Section { | ||
NavigationLink { | ||
EditorView(configuration: .default) | ||
Button { | ||
isShowingDefaultEditor = true | ||
} label: { | ||
Text("Bundled Editor") | ||
} | ||
} | ||
|
||
Section { | ||
Toggle("Native Block Inserter", isOn: $enableNativeBlockInserter) | ||
Toggle("Enable Plugins", isOn: $enablePlugins) | ||
Toggle("Hide Title", isOn: $hideTitle) | ||
Toggle("Auto Focus on Load", isOn: $autoFocusOnLoad) | ||
Toggle("Theme Styles", isOn: $themeStyles) | ||
} header: { | ||
Text("Configuration") | ||
} footer: { | ||
Button("Reset") { | ||
enableNativeBlockInserter = true | ||
enablePlugins = false | ||
hideTitle = false | ||
autoFocusOnLoad = true | ||
themeStyles = true | ||
} | ||
.padding(.vertical, 12) | ||
} | ||
|
||
Section { | ||
ForEach(remoteEditorConfigurations, id: \.siteURL) { configuration in | ||
NavigationLink { | ||
EditorView(configuration: configuration) | ||
EditorView(configuration: configureWithSettings(configuration)) | ||
} label: { | ||
Text(URL(string: configuration.siteURL)?.host ?? configuration.siteURL) | ||
} | ||
|
@@ -39,6 +67,11 @@ struct ContentView: View { | |
} | ||
} | ||
} | ||
.fullScreenCover(isPresented: $isShowingDefaultEditor) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed it to show modally as in the app. |
||
NavigationView { | ||
EditorView(configuration: configureWithSettings(.default)) | ||
} | ||
} | ||
.toolbar { | ||
ToolbarItem(placement: .primaryAction) { | ||
Button { | ||
|
@@ -57,19 +90,27 @@ struct ContentView: View { | |
} label: { | ||
Image(systemName: "arrow.clockwise") | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
// Helper function to apply settings to configuration | ||
private func configureWithSettings(_ configuration: EditorConfiguration) -> EditorConfiguration { | ||
var config = configuration | ||
config.enableNativeBlockInserter = enableNativeBlockInserter | ||
config.plugins = enablePlugins | ||
config.hideTitle = hideTitle | ||
config.autoFocusOnLoad = autoFocusOnLoad | ||
config.themeStyles = themeStyles | ||
return config | ||
} | ||
} | ||
|
||
private extension EditorConfiguration { | ||
|
||
static var template: Self { | ||
var configuration = EditorConfiguration.default | ||
|
||
#warning("1. Update the property values below") | ||
#warning("2. Install the Jetpack plugin to the site") | ||
configuration.siteURL = "https://modify-me.com" | ||
configuration.authHeader = "Insert the Authorization header value here" | ||
|
||
|
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 used some iOS 16 APIs. The apps require iOS 16, so we are good.