v1.0.4: Fix tiptapToMarkdown JsonElement type casting
- tiptapToMarkdown used JsonObject.asMap() which returns Map<String, JsonElement> - All 'as? String' casts silently failed (JsonPrimitive != String), returning empty - Now uses Gson TypeToken<Map<String, Any?>> for proper raw type deserialization - contentToMarkdown now handles Map types directly without serialize roundtrip
This commit is contained in:
@@ -20,8 +20,8 @@ android {
|
||||
applicationId = "com.docmost.app"
|
||||
minSdk = 26
|
||||
targetSdk = 34
|
||||
versionCode = 4
|
||||
versionName = "1.0.3"
|
||||
versionCode = 5
|
||||
versionName = "1.0.4"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
|
||||
@@ -1877,9 +1877,9 @@ class PageEditorActivity : AppCompatActivity() {
|
||||
|
||||
private fun tiptapToMarkdown(tiptapJson: String): String {
|
||||
return try {
|
||||
val doc = gson.fromJson(tiptapJson, com.google.gson.JsonObject::class.java).asMap()
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
extractText(doc as Map<String, Any?>)
|
||||
val type = object : com.google.gson.reflect.TypeToken<Map<String, Any?>>() {}.type
|
||||
val doc: Map<String, Any?> = gson.fromJson(tiptapJson, type)
|
||||
extractText(doc)
|
||||
} catch (e: Exception) {
|
||||
tiptapJson
|
||||
}
|
||||
@@ -2492,6 +2492,15 @@ class PageEditorActivity : AppCompatActivity() {
|
||||
content
|
||||
}
|
||||
}
|
||||
if (content is Map<*, *>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return try {
|
||||
extractText(content as Map<String, Any?>)
|
||||
} catch (e: Exception) {
|
||||
android.util.Log.e("PageEditor", "contentToMarkdown map error: ${e.message}")
|
||||
""
|
||||
}
|
||||
}
|
||||
return try {
|
||||
val json = gson.toJson(content)
|
||||
if (json.isNotEmpty() && json != "null") {
|
||||
|
||||
Reference in New Issue
Block a user