Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.wordpress.gutenberg

import android.os.Parcelable
import android.os.Parcel
import kotlinx.parcelize.Parcelize

@Parcelize
Expand Down Expand Up @@ -60,7 +59,8 @@ open class EditorConfiguration constructor(
val siteApiNamespace: Array<String>,
val namespaceExcludedPaths: Array<String>,
val authHeader: String,
val webViewGlobals: List<WebViewGlobal>
val webViewGlobals: List<WebViewGlobal>,
val editorSettings: String?
) : Parcelable {
companion object {
@JvmStatic
Expand All @@ -81,6 +81,7 @@ open class EditorConfiguration constructor(
private var namespaceExcludedPaths: Array<String> = arrayOf()
private var authHeader: String = ""
private var webViewGlobals: List<WebViewGlobal> = emptyList()
private var editorSettings: String? = null

fun setTitle(title: String) = apply { this.title = title }
fun setContent(content: String) = apply { this.content = content }
Expand All @@ -95,6 +96,7 @@ open class EditorConfiguration constructor(
fun setNamespaceExcludedPaths(namespaceExcludedPaths: Array<String>) = apply { this.namespaceExcludedPaths = namespaceExcludedPaths }
fun setAuthHeader(authHeader: String) = apply { this.authHeader = authHeader }
fun setWebViewGlobals(webViewGlobals: List<WebViewGlobal>) = apply { this.webViewGlobals = webViewGlobals }
fun setEditorSettings(editorSettings: String?) = apply { this.editorSettings = editorSettings }

fun build(): EditorConfiguration = EditorConfiguration(
title = title,
Expand All @@ -109,7 +111,8 @@ open class EditorConfiguration constructor(
siteApiNamespace = siteApiNamespace,
namespaceExcludedPaths = namespaceExcludedPaths,
authHeader = authHeader,
webViewGlobals = webViewGlobals
webViewGlobals = webViewGlobals,
editorSettings = editorSettings
)
}

Expand All @@ -132,6 +135,7 @@ open class EditorConfiguration constructor(
if (!namespaceExcludedPaths.contentEquals(other.namespaceExcludedPaths)) return false
if (authHeader != other.authHeader) return false
if (webViewGlobals != other.webViewGlobals) return false
if (editorSettings != other.editorSettings) return false

return true
}
Expand All @@ -150,6 +154,7 @@ open class EditorConfiguration constructor(
result = 31 * result + namespaceExcludedPaths.contentHashCode()
result = 31 * result + authHeader.hashCode()
result = 31 * result + webViewGlobals.hashCode()
result = 31 * result + (editorSettings?.hashCode() ?: 0)
return result
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class GutenbergView : WebView {

val escapedTitle = encodeForEditor(configuration.title)
val escapedContent = encodeForEditor(configuration.content)
val editorSettings = configuration.editorSettings ?: "undefined"

val gbKitConfig = """
window.GBKit = {
Expand All @@ -269,6 +270,7 @@ class GutenbergView : WebView {
"authHeader": "${configuration.authHeader}",
"themeStyles": ${configuration.themeStyles},
"hideTitle": ${configuration.hideTitle},
"editorSettings": $editorSettings,
${if (configuration.postId != null) """
"post": {
"id": ${configuration.postId},
Expand Down
4 changes: 0 additions & 4 deletions ios/Sources/GutenbergKit/Gutenberg/assets/index-CH3ipafv.js

This file was deleted.

Loading