@@ -16,6 +16,9 @@ public struct EditorConfiguration {
1616 public let shouldUsePlugins : Bool
1717 /// Toggles visibility of the title field
1818 public let shouldHideTitle : Bool
19+ /// If enabled, the editor automatically becomes focused when initialized
20+ /// with an empty content.
21+ public let shouldAutoFocus : Bool
1922 /// Root URL for the site
2023 public let siteURL : String
2124 /// Root URL for the site API
@@ -42,6 +45,7 @@ public struct EditorConfiguration {
4245 shouldUseThemeStyles: Bool ,
4346 shouldUsePlugins: Bool ,
4447 shouldHideTitle: Bool ,
48+ shouldAutoFocus: Bool ,
4549 siteURL: String ,
4650 siteApiRoot: String ,
4751 siteApiNamespace: [ String ] ,
@@ -58,6 +62,7 @@ public struct EditorConfiguration {
5862 self . shouldUseThemeStyles = shouldUseThemeStyles
5963 self . shouldUsePlugins = shouldUsePlugins
6064 self . shouldHideTitle = shouldHideTitle
65+ self . shouldAutoFocus = shouldAutoFocus
6166 self . siteURL = siteURL
6267 self . siteApiRoot = siteApiRoot
6368 self . siteApiNamespace = siteApiNamespace
@@ -77,6 +82,7 @@ public struct EditorConfiguration {
7782 shouldUseThemeStyles: shouldUseThemeStyles,
7883 shouldUsePlugins: shouldUsePlugins,
7984 shouldHideTitle: shouldHideTitle,
85+ shouldAutoFocus: shouldAutoFocus,
8086 siteURL: siteURL,
8187 siteApiRoot: siteApiRoot,
8288 siteApiNamespace: siteApiNamespace,
@@ -107,6 +113,7 @@ public struct EditorConfigurationBuilder {
107113 private var shouldUseThemeStyles : Bool
108114 private var shouldUsePlugins : Bool
109115 private var shouldHideTitle : Bool
116+ private var shouldAutoFocus : Bool
110117 private var siteURL : String
111118 private var siteApiRoot : String
112119 private var siteApiNamespace : [ String ]
@@ -124,6 +131,7 @@ public struct EditorConfigurationBuilder {
124131 shouldUseThemeStyles: Bool = false ,
125132 shouldUsePlugins: Bool = false ,
126133 shouldHideTitle: Bool = false ,
134+ shouldAutoFocus: Bool = true ,
127135 siteURL: String = " " ,
128136 siteApiRoot: String = " " ,
129137 siteApiNamespace: [ String ] = [ ] ,
@@ -140,6 +148,7 @@ public struct EditorConfigurationBuilder {
140148 self . shouldUseThemeStyles = shouldUseThemeStyles
141149 self . shouldUsePlugins = shouldUsePlugins
142150 self . shouldHideTitle = shouldHideTitle
151+ self . shouldAutoFocus = shouldAutoFocus
143152 self . siteURL = siteURL
144153 self . siteApiRoot = siteApiRoot
145154 self . siteApiNamespace = siteApiNamespace
@@ -192,6 +201,12 @@ public struct EditorConfigurationBuilder {
192201 return copy
193202 }
194203
204+ public func setShouldAutoFocus( _ shouldAutoFocus: Bool ) -> EditorConfigurationBuilder {
205+ var copy = self
206+ copy. shouldAutoFocus = shouldAutoFocus
207+ return copy
208+ }
209+
195210 public func setSiteUrl( _ siteUrl: String ) -> EditorConfigurationBuilder {
196211 var copy = self
197212 copy. siteURL = siteUrl
@@ -271,6 +286,7 @@ public struct EditorConfigurationBuilder {
271286 shouldUseThemeStyles: shouldUseThemeStyles,
272287 shouldUsePlugins: shouldUsePlugins,
273288 shouldHideTitle: shouldHideTitle,
289+ shouldAutoFocus: shouldAutoFocus,
274290 siteURL: siteURL,
275291 siteApiRoot: siteApiRoot,
276292 siteApiNamespace: siteApiNamespace,
0 commit comments