Skip to content

Instantly share code, notes, and snippets.

@hypest
Created May 6, 2019 17:19
Show Gist options
  • Save hypest/2c9b46e5a20fbbb5a098d345e14071cf to your computer and use it in GitHub Desktop.
Save hypest/2c9b46e5a20fbbb5a098d345e14071cf to your computer and use it in GitHub Desktop.
Trying to use Aztec from source in gutenberg-mobile
diff --git a/app/build.gradle b/app/build.gradle
index 25384818..c9669794 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -2,13 +2,13 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
- compileSdkVersion 27
+ compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "org.wordpress.aztec"
minSdkVersion 16
- targetSdkVersion 27
+ targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
@@ -40,7 +40,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
- implementation "com.android.support:appcompat-v7:$supportLibVersion"
+ implementation "com.android.support:appcompat-v7:27.1.1"
implementation "org.wordpress:utils:$wordpressUtilsVersion"
androidTestImplementation "com.android.support.test.espresso:espresso-core:$espressoVersion", {
diff --git a/aztec/build.gradle b/aztec/build.gradle
index 51d6c76b..7d1ed661 100644
--- a/aztec/build.gradle
+++ b/aztec/build.gradle
@@ -2,12 +2,12 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
- compileSdkVersion 27
+ compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
minSdkVersion 16
- targetSdkVersion 27
+ targetSdkVersion 28
versionName "1.0"
}
@@ -44,8 +44,8 @@ dependencies {
implementation "org.ccil.cowan.tagsoup:tagsoup:$tagSoupVersion"
implementation "org.jsoup:jsoup:$jSoupVersion"
- implementation "com.android.support:support-v4:$supportLibVersion"
- implementation "com.android.support:design:$supportLibVersion"
+ implementation "com.android.support:support-v4:27.1.1"
+ implementation "com.android.support:design:27.1.1"
implementation "org.wordpress:utils:$wordpressUtilsVersion"
diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/AztecExceptionHandler.kt b/aztec/src/main/kotlin/org/wordpress/aztec/AztecExceptionHandler.kt
index f5aff854..fd182920 100644
--- a/aztec/src/main/kotlin/org/wordpress/aztec/AztecExceptionHandler.kt
+++ b/aztec/src/main/kotlin/org/wordpress/aztec/AztecExceptionHandler.kt
@@ -31,7 +31,7 @@ class AztecExceptionHandler(private val logHelper: ExceptionHandlerHelper?, priv
// Try to report the HTML code of the content, the spans details, but do not report exceptions that can occur logging the content
try {
AppLog.e(AppLog.T.EDITOR, "HTML content of Aztec Editor before the crash:")
- AppLog.e(AppLog.T.EDITOR, visualEditor.toPlainHtml(false))
+ AppLog.e(AppLog.T.EDITOR, visualEditor.toPlainHtml(visualEditor.text, false))
} catch (e: Throwable) {
AppLog.e(AppLog.T.EDITOR, "Oops! There was an error logging the HTML code.")
}
diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt b/aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt
index fc414a3f..8038b2de 100644
--- a/aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt
+++ b/aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt
@@ -47,14 +47,17 @@ import android.text.TextWatcher
import android.text.style.SuggestionSpan
import android.util.AttributeSet
import android.util.DisplayMetrics
+import android.util.Log
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.BaseInputConnection
+import android.view.inputmethod.EditorInfo
import android.widget.CheckBox
import android.widget.EditText
+import android.widget.TextView
import android.widget.Toast
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
@@ -320,7 +323,8 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
}
interface OnAztecKeyListener {
- fun onEnterKey(firedAfterTextChanged: Boolean) : Boolean
+ fun onEnterKey(textBefore: Spanned, cursorPositionStart: Int, cursorPositionEnd: Int,
+ firedAfterTextChanged: Boolean) : Boolean
fun onBackspaceKey(firedAfterTextChanged: Boolean) : Boolean
}
@@ -520,7 +524,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
if (event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER) {
// Check if the external listener has consumed the enter pressed event
// In that case stop the execution
- if (onAztecKeyListener?.onEnterKey(false) == true) {
+ if (onAztecKeyListener?.onEnterKey(text, selectionStart, selectionEnd, false) == true) {
return true
}
}
@@ -559,8 +563,16 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
// Keep the enter pressed watcher at the beginning of the watchers list.
// We want to intercept Enter.key as soon as possible, and before other listeners start modifying the text.
// Also note that this Watchers, when the AztecKeyListener is set, keep hold a copy of the content in the editor.
- EnterPressedWatcher.install(this)
+// EnterPressedWatcher.install(this)
+ setOnEditorActionListener(object : OnEditorActionListener {
+ override fun onEditorAction(v: TextView?, actionId: Int, event: KeyEvent?): Boolean {
+ if (actionId == EditorInfo.IME_ACTION_DONE) {
+ return true;
+ }
+ return false;
+ }
+ })
ParagraphBleedAdjuster.install(this)
ParagraphCollapseAdjuster.install(this)
@@ -577,8 +589,8 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
BlockElementWatcher(this)
.add(HeadingHandler())
- .add(ListHandler())
- .add(ListItemHandler())
+// .add(ListHandler())
+// .add(ListItemHandler())
.add(QuoteHandler())
.add(PreformatHandler())
.install(this)
@@ -725,7 +737,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
InstanceStateUtils.writeTempInstance(context, externalLogger, INPUT_LAST_KEY, history.inputLast, bundle)
bundle.putInt(VISIBILITY_KEY, visibility)
bundle.putByteArray(RETAINED_INITIAL_HTML_PARSED_SHA256_KEY, initialEditorContentParsedSHA256)
- InstanceStateUtils.writeTempInstance(context, externalLogger, RETAINED_HTML_KEY, toHtml(false), bundle)
+ InstanceStateUtils.writeTempInstance(context, externalLogger, RETAINED_HTML_KEY, toHtml(text, false), bundle)
bundle.putInt(SELECTION_START_KEY, selectionStart)
bundle.putInt(SELECTION_END_KEY, selectionEnd)
@@ -1065,6 +1077,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
}
override fun beforeTextChanged(text: CharSequence, start: Int, count: Int, after: Int) {
+ Log.v("qwet", "betc: $text")
addWatcherNestingLevel()
if (!isViewInitialized) return
@@ -1077,6 +1090,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
}
override fun onTextChanged(text: CharSequence, start: Int, before: Int, count: Int) {
+ Log.v("qwet", "ontc: $text")
if (!isViewInitialized) return
if (isEventObservableCandidate()) {
@@ -1087,6 +1101,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
}
override fun afterTextChanged(text: Editable) {
+ Log.v("qwet", "aftc: $text")
if (isTextChangedListenerDisabled()) {
subWatcherNestingLevel()
return
@@ -1154,7 +1169,8 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
setSelection(cursorPosition)
if (isInit) {
- initialEditorContentParsedSHA256 = calculateInitialHTMLSHA(toPlainHtml(false), initialEditorContentParsedSHA256)
+ initialEditorContentParsedSHA256 = calculateInitialHTMLSHA(toPlainHtml(text, false),
+ initialEditorContentParsedSHA256)
}
loadImages()
@@ -1232,12 +1248,12 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
}
open fun hasChanges(): EditorHasChanges {
- return hasChanges(initialEditorContentParsedSHA256, toPlainHtml(false))
+ return hasChanges(initialEditorContentParsedSHA256, toPlainHtml(text, false))
}
// returns regular or "calypso" html depending on the mode
- fun toHtml(withCursorTag: Boolean = false): String {
- val html = toPlainHtml(withCursorTag)
+ fun toHtml(inputText: Spanned, withCursorTag: Boolean = false): String {
+ val html = toPlainHtml(inputText, withCursorTag)
if (isInCalypsoMode) {
// calypso format is a mix of newline characters and html
@@ -1249,23 +1265,23 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
}
// platform agnostic HTML
- fun toPlainHtml(withCursorTag: Boolean = false): String {
+ fun toPlainHtml(inputText: Spanned, withCursorTag: Boolean = false): String {
return if (Looper.myLooper() != Looper.getMainLooper()) {
runBlocking {
withContext(Dispatchers.Main) {
- parseHtml(withCursorTag)
+ parseHtml(inputText, withCursorTag)
}
}
} else {
- parseHtml(withCursorTag)
+ parseHtml(inputText, withCursorTag)
}
}
- private fun parseHtml(withCursorTag: Boolean): String {
+ private fun parseHtml(inputText: Spanned, withCursorTag: Boolean): String {
val parser = AztecParser(plugins)
val output: SpannableStringBuilder
try {
- output = SpannableStringBuilder(text)
+ output = SpannableStringBuilder(inputText)
} catch (e: Exception) {
// FIXME: Remove this log once we've data to replicate the issue, and fix it in some way.
AppLog.e(AppLog.T.EDITOR, "There was an error creating SpannableStringBuilder. See #452 and #582 for details.")
@@ -1289,8 +1305,8 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
return EndOfBufferMarkerAdder.removeEndOfTextMarker(parser.toHtml(output, withCursorTag))
}
- fun toFormattedHtml(): String {
- return Format.addSourceEditorFormatting(toHtml(), isInCalypsoMode)
+ fun toFormattedHtml(inputText: Editable): String {
+ return Format.addSourceEditorFormatting(toHtml(inputText), isInCalypsoMode)
}
private fun switchToAztecStyle(editable: Editable, start: Int, end: Int) {
@@ -1566,7 +1582,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
val textToPaste = if (asPlainText) clip.getItemAt(0).coerceToText(context).toString()
else clip.getItemAt(0).coerceToHtmlText(AztecParser(plugins))
- val oldHtml = toPlainHtml().replace("<aztec_cursor>", "")
+ val oldHtml = toPlainHtml(editable).replace("<aztec_cursor>", "")
val newHtml = oldHtml.replace(Constants.REPLACEMENT_MARKER_STRING, textToPaste + "<" + AztecCursorSpan.AZTEC_CURSOR_TAG + ">")
fromHtml(newHtml, false)
diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/History.kt b/aztec/src/main/kotlin/org/wordpress/aztec/History.kt
index 49c5cd42..831b2b54 100644
--- a/aztec/src/main/kotlin/org/wordpress/aztec/History.kt
+++ b/aztec/src/main/kotlin/org/wordpress/aztec/History.kt
@@ -39,7 +39,7 @@ class History(val historyEnabled: Boolean, val historySize: Int) {
textChangedPending = true
historyRunnable?.text =
when (editText) {
- is AztecText -> editText.toFormattedHtml()
+ is AztecText -> editText.toFormattedHtml(editText.text)
is SourceViewEditText -> editText.text.toString()
else -> ""
}
@@ -52,7 +52,7 @@ class History(val historyEnabled: Boolean, val historySize: Int) {
protected fun doHandleHistory(inputBefore: String, editText: EditText?) {
textChangedPending = false
inputLast = when (editText) {
- is AztecText -> editText.toFormattedHtml()
+ is AztecText -> editText.toFormattedHtml(editText.text)
is SourceViewEditText -> editText.text.toString()
else -> ""
}
@@ -85,7 +85,7 @@ class History(val historyEnabled: Boolean, val historySize: Int) {
return
}
if (editText is AztecText) {
- inputLast = editText.toFormattedHtml()
+ inputLast = editText.toFormattedHtml(editText.text)
} else if (editText is SourceViewEditText) {
inputLast = editText.text.toString()
}
diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/formatting/InlineFormatter.kt b/aztec/src/main/kotlin/org/wordpress/aztec/formatting/InlineFormatter.kt
index 0f4f86f4..476310c9 100644
--- a/aztec/src/main/kotlin/org/wordpress/aztec/formatting/InlineFormatter.kt
+++ b/aztec/src/main/kotlin/org/wordpress/aztec/formatting/InlineFormatter.kt
@@ -183,12 +183,12 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
if (extLogger != null) {
extLogger.log("InlineFormatter.applySpan - setSpan has end before start." +
" Start:" + start + " End:" + end)
- extLogger.log("Logging the whole content" + editor.toPlainHtml())
+ extLogger.log("Logging the whole content" + editor.toPlainHtml(editor.text))
}
// Now log in the default log
AppLog.w(AppLog.T.EDITOR, "InlineFormatter.applySpan - setSpan has end before start." +
" Start:" + start + " End:" + end)
- AppLog.w(AppLog.T.EDITOR, "Logging the whole content" + editor.toPlainHtml())
+ AppLog.w(AppLog.T.EDITOR, "Logging the whole content" + editor.toPlainHtml(editor.text))
return
}
editableText.setSpan(span, start, end, type)
diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/toolbar/AztecToolbar.kt b/aztec/src/main/kotlin/org/wordpress/aztec/toolbar/AztecToolbar.kt
index d9014c30..89414166 100644
--- a/aztec/src/main/kotlin/org/wordpress/aztec/toolbar/AztecToolbar.kt
+++ b/aztec/src/main/kotlin/org/wordpress/aztec/toolbar/AztecToolbar.kt
@@ -573,7 +573,7 @@ class AztecToolbar : FrameLayout, IAztecToolbar, OnMenuItemClickListener {
}
private fun syncSourceFromEditor() {
- val editorHtml = editor!!.toPlainHtml(true)
+ val editorHtml = editor!!.toPlainHtml(editor!!.text, true)
val sha256 = AztecText.calculateSHA256(editorHtml)
if (editorContentParsedSHA256LastSwitch.isEmpty()) {
diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/util/Azteclog.kt b/aztec/src/main/kotlin/org/wordpress/aztec/util/Azteclog.kt
index fd36d62d..b16a9b50 100644
--- a/aztec/src/main/kotlin/org/wordpress/aztec/util/Azteclog.kt
+++ b/aztec/src/main/kotlin/org/wordpress/aztec/util/Azteclog.kt
@@ -33,7 +33,7 @@ class AztecLog {
}
}
- private fun logSpansDetails(text: Spanned): String {
+ @JvmStatic fun logSpansDetails(text: Spanned): String {
val spans = text.getSpans(0, text.length, Any::class.java)
val spansList = Arrays.asList<Any>(*spans)
@@ -117,4 +117,4 @@ class AztecLog {
return TextUtils.join("", Collections.nCopies(count, char))
}
}
-}
\ No newline at end of file
+}
diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/watchers/EnterPressedWatcher.kt b/aztec/src/main/kotlin/org/wordpress/aztec/watchers/EnterPressedWatcher.kt
index 4f912c58..6d8292fb 100644
--- a/aztec/src/main/kotlin/org/wordpress/aztec/watchers/EnterPressedWatcher.kt
+++ b/aztec/src/main/kotlin/org/wordpress/aztec/watchers/EnterPressedWatcher.kt
@@ -3,6 +3,7 @@ package org.wordpress.aztec.watchers
import android.text.Editable
import android.text.SpannableStringBuilder
+import android.text.Spanned
import android.text.TextWatcher
import org.wordpress.aztec.AztecText
import org.wordpress.aztec.Constants
@@ -11,8 +12,10 @@ import java.lang.ref.WeakReference
class EnterPressedWatcher(aztecText: AztecText) : TextWatcher {
private val aztecTextRef: WeakReference<AztecText?> = WeakReference(aztecText)
- private var textBefore : SpannableStringBuilder? = null
+ private lateinit var textBefore : Spanned
private var start: Int = -1
+ private var cursorPositionStart: Int = 0
+ private var cursorPositionEnd: Int = 0
override fun beforeTextChanged(text: CharSequence, start: Int, count: Int, after: Int) {
val aztecText = aztecTextRef.get()
@@ -20,6 +23,9 @@ class EnterPressedWatcher(aztecText: AztecText) : TextWatcher {
// we need to make a copy to preserve the contents as they were before the change
textBefore = SpannableStringBuilder(text)
this.start = start
+
+ cursorPositionStart = aztecText.getSelectionStart()
+ cursorPositionEnd = aztecText.getSelectionEnd()
}
}
@@ -29,10 +35,10 @@ class EnterPressedWatcher(aztecText: AztecText) : TextWatcher {
if (aztecText != null && !aztecText.isTextChangedListenerDisabled() && aztecKeyListener != null) {
val newTextCopy = SpannableStringBuilder(text)
// if new text length is longer than original text by 1
- if (textBefore?.length == newTextCopy.length - 1) {
+ if (textBefore.length == newTextCopy.length - 1) {
// now check that the inserted character is actually a NEWLINE
if (newTextCopy[this.start] == Constants.NEWLINE) {
- aztecKeyListener.onEnterKey(true)
+ aztecKeyListener.onEnterKey(newTextCopy, cursorPositionStart, cursorPositionEnd, true)
}
}
}
diff --git a/glide-loader/build.gradle b/glide-loader/build.gradle
index 928ea0db..0f2ab93d 100644
--- a/glide-loader/build.gradle
+++ b/glide-loader/build.gradle
@@ -2,12 +2,12 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
- compileSdkVersion 27
+ compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
minSdkVersion 16
- targetSdkVersion 27
+ targetSdkVersion 28
versionCode 1
versionName "1.0"
diff --git a/picasso-loader/build.gradle b/picasso-loader/build.gradle
index e668ef2e..3ec7326e 100644
--- a/picasso-loader/build.gradle
+++ b/picasso-loader/build.gradle
@@ -2,12 +2,12 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
- compileSdkVersion 27
+ compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
minSdkVersion 16
- targetSdkVersion 27
+ targetSdkVersion 28
versionCode 1
versionName "1.0"
}
@@ -25,8 +25,8 @@ dependencies {
implementation project(':aztec')
- implementation "com.android.support:support-v4:$supportLibVersion"
- implementation "com.android.support:design:$supportLibVersion"
+ implementation "com.android.support:support-v4:27.1.1"
+ implementation "com.android.support:design:27.1.1"
implementation "com.squareup.picasso:picasso:$picassoVersion"
}
diff --git a/wordpress-comments/build.gradle b/wordpress-comments/build.gradle
index 8dd311f9..f8dcb7d1 100644
--- a/wordpress-comments/build.gradle
+++ b/wordpress-comments/build.gradle
@@ -2,12 +2,12 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
- compileSdkVersion 27
+ compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
minSdkVersion 16
- targetSdkVersion 27
+ targetSdkVersion 28
versionName "1.0"
}
@@ -36,8 +36,8 @@ dependencies {
implementation project(':aztec')
- implementation "com.android.support:support-v4:$supportLibVersion"
- implementation "com.android.support:design:$supportLibVersion"
+ implementation "com.android.support:support-v4:27.1.1"
+ implementation "com.android.support:design:27.1.1"
implementation "org.wordpress:utils:$wordpressUtilsVersion"
testImplementation "junit:junit:$jUnitVersion"
diff --git a/wordpress-shortcodes/build.gradle b/wordpress-shortcodes/build.gradle
index 9c481844..8d4d1451 100644
--- a/wordpress-shortcodes/build.gradle
+++ b/wordpress-shortcodes/build.gradle
@@ -2,12 +2,12 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
- compileSdkVersion 27
+ compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 16
- targetSdkVersion 27
+ targetSdkVersion 28
versionName "1.0"
}
@@ -36,7 +36,7 @@ dependencies {
implementation project(':aztec')
- implementation "com.android.support:appcompat-v7:$supportLibVersion"
+ implementation "com.android.support:appcompat-v7:27.1.1"
testImplementation "junit:junit:$jUnitVersion"
testImplementation "org.robolectric:robolectric:$robolectricVersion"
diff --git a/android/build.gradle b/android/build.gradle
index 9137dbcd..66e1d520 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,13 +1,23 @@
buildscript {
ext {
gradlePluginVersion = '3.3.1'
- kotlinVersion = '1.3.0'
+ kotlinVersion = '1.3.11'
+
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
+
+ kotlinCoroutinesVersion = '1.1.0'
supportLibVersion = '28.0.0'
+ tagSoupVersion = '1.2.1'
+ glideVersion = '3.7.0'
+ picassoVersion = '2.5.2'
+ robolectricVersion = '3.5.1'
+ jUnitVersion = '4.12'
+ jSoupVersion = '1.11.3'
wordpressUtilsVersion = '1.22'
+ espressoVersion = '3.0.1'
}
repositories {
google()
diff --git a/android/settings.gradle b/android/settings.gradle
index 81fcc569..cf7423bc 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -9,3 +9,12 @@ include ':react-native-gutenberg-bridge'
project(':react-native-gutenberg-bridge').projectDir = new File(rootProject.projectDir, '../react-native-gutenberg-bridge/android')
include ':app'
+
+include ':aztecdemo', ':aztec', ':glide-loader', ':wordpress-comments', ':wordpress-shortcodes', ':picasso-loader'
+project(':aztecdemo').projectDir = new File(rootProject.projectDir, '../../../../../../WordPress-Aztec-Android/app')
+project(':aztec').projectDir = new File(rootProject.projectDir, '../../../../../../WordPress-Aztec-Android/aztec')
+project(':glide-loader').projectDir = new File(rootProject.projectDir, '../../../../../../WordPress-Aztec-Android/glide-loader')
+project(':wordpress-comments').projectDir = new File(rootProject.projectDir, '../../../../../../WordPress-Aztec-Android/wordpress-comments')
+project(':wordpress-shortcodes').projectDir = new File(rootProject.projectDir, '../../../../../../WordPress-Aztec-Android/wordpress-shortcodes')
+
+project(':picasso-loader').projectDir = new File(rootProject.projectDir, '../../../../../../WordPress-Aztec-Android/picasso-loader')
diff --git a/react-native-aztec/android/build.gradle b/react-native-aztec/android/build.gradle
index d4832192..8f410c40 100644
--- a/react-native-aztec/android/build.gradle
+++ b/react-native-aztec/android/build.gradle
@@ -1,14 +1,21 @@
buildscript {
ext {
gradlePluginVersion = '3.3.1'
- kotlinVersion = '1.2.31'
+ kotlinVersion = '1.3.11'
+
+ buildToolsVersion = "28.0.3"
+ minSdkVersion = 21
+ compileSdkVersion = 28
+ targetSdkVersion = 28
+
+ kotlinCoroutinesVersion = '1.1.0'
supportLibVersion = '28.0.0'
tagSoupVersion = '1.2.1'
glideVersion = '3.7.0'
picassoVersion = '2.5.2'
robolectricVersion = '3.5.1'
jUnitVersion = '4.12'
- jSoupVersion = '1.10.3'
+ jSoupVersion = '1.11.3'
wordpressUtilsVersion = '1.22'
espressoVersion = '3.0.1'
@@ -92,10 +99,10 @@ repositories {
}
dependencies {
- api ("com.github.wordpress-mobile.WordPress-Aztec-Android:aztec:$aztecVersion")
- api ("com.github.wordpress-mobile.WordPress-Aztec-Android:wordpress-shortcodes:$aztecVersion")
- api ("com.github.wordpress-mobile.WordPress-Aztec-Android:wordpress-comments:$aztecVersion")
- api ("com.github.wordpress-mobile.WordPress-Aztec-Android:glide-loader:$aztecVersion")
+ api project(':aztec')
+ api project(':wordpress-shortcodes')
+ api project(':wordpress-comments')
+ api project(':glide-loader')
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
diff --git a/react-native-aztec/android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecManager.java b/react-native-aztec/android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecManager.java
index 76cab3b7..316c6577 100644
--- a/react-native-aztec/android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecManager.java
+++ b/react-native-aztec/android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecManager.java
@@ -7,6 +7,7 @@ import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
+import android.util.Log;
import android.util.TypedValue;
import android.view.View;
@@ -168,6 +169,7 @@ public class ReactAztecManager extends SimpleViewManager<ReactAztecText> {
@ReactProp(name = "text")
public void setText(ReactAztecText view, ReadableMap inputMap) {
if (!inputMap.hasKey("eventCount")) {
+ Log.v("qwer", "setText without eventCount");
setTextfromJS(view, inputMap.getString("text"), inputMap.getMap("selection"));
} else {
// Don't think there is necessity of this branch, but justin case we want to
@@ -175,12 +177,14 @@ public class ReactAztecManager extends SimpleViewManager<ReactAztecText> {
int eventCount = inputMap.getInt("eventCount");
if (view.mNativeEventCount < eventCount) {
+ Log.v("qwer", "setText with newer eventCount");
setTextfromJS(view, inputMap.getString("text"), inputMap.getMap("selection"));
}
}
}
private void setTextfromJS(ReactAztecText view, String text, @Nullable ReadableMap selection) {
+ Log.v("qwer", "setTextfromJS with: " + text);
view.setIsSettingTextFromJS(true);
view.disableOnSelectionListener();
view.fromHtml(text, true);
diff --git a/react-native-gutenberg-bridge/android/build.gradle b/react-native-gutenberg-bridge/android/build.gradle
index 86df45d3..f3c96810 100644
--- a/react-native-gutenberg-bridge/android/build.gradle
+++ b/react-native-gutenberg-bridge/android/build.gradle
@@ -114,6 +114,7 @@ repositories {
dependencies {
implementation project(':react-native-aztec')
+ implementation "org.wordpress:utils:$wordpressUtilsVersion"
if (rootProject.ext.buildGutenbergFromSource) {
println "using gutenberg from source"
diff --git a/src/app/initial-html.js b/src/app/initial-html.js
index 38d61f66..ed8bd829 100644
--- a/src/app/initial-html.js
+++ b/src/app/initial-html.js
@@ -4,202 +4,10 @@
*/
export default `
-<!-- wp:image -->
-<figure class="wp-block-image"><img alt=""/></figure>
-<!-- /wp:image -->
-
-<!-- wp:image -->
-<figure class="wp-block-image"><img src="https://cldup.com/cXyG__fTLN.jpg" alt=""/></figure>
-<!-- /wp:image -->
-
-<!-- wp:title -->
-Hello World
-<!-- /wp:title -->
-
-<!-- wp:heading {"level": 2} -->
-<h2>What is Gutenberg?</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p><b>Hello</b> World!</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:nextpage -->
-<!--nextpage-->
-<!-- /wp:nextpage -->
-
-<!-- wp:paragraph {"dropCap":true,"backgroundColor":"vivid-red","fontSize":"large","className":"custom-class-1 custom-class-2"} -->
-<p class="has-background has-drop-cap has-large-font-size has-vivid-red-background-color custom-class-1 custom-class-2">
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempor tincidunt sapien, quis dictum orci sollicitudin quis. Proin sed elit id est pulvinar feugiat vitae eget dolor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
-<!-- /wp:paragraph -->
-
-
-<!-- wp:code -->
-<pre class="wp-block-code"><code>if name == "World":
- return "Hello World"
-else:
- return "Hello Pony"</code></pre>
-<!-- /wp:code -->
-
-<!-- wp:more -->
-<!--more-->
-<!-- /wp:more -->
-
-<!-- wp:p4ragraph -->
-Лорем ипсум долор сит амет, адиписци трацтатос еа еум. Меа аудиам малуиссет те, хас меис либрис елеифенд ин. Нец ех тота деленит сусципит. Яуас порро инструцтиор но нец.
-<!-- /wp:p4ragraph -->
-
-<!-- wp:paragraph {"customTextColor":"#6c7781","customFontSize":17} -->
-<p style="color:#6c7781;font-size:17px" class="has-text-color"><em>It’s a whole new way to use WordPress. Try it right here!</em></p>
-<!-- /wp:paragraph -->
-
-<!-- wp:image {"id":97629,"align":"full"} -->
-<figure class="wp-block-image alignfull"><img src="https://wordpress.org/gutenberg/files/2018/07/Screenshot-4-1.png" alt="" class="wp-image-97629"/></figure>
-<!-- /wp:image -->
-
-<!-- wp:paragraph {"align":"left"} -->
-<p style="text-align:left">We call the new editor Gutenberg. The entire editing experience has been rebuilt for media rich pages and posts. Experience the flexibility that blocks will bring, whether you are building your first site, or write code for a living.</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:gallery {"ids":[null,null,null,null],"columns":4,"align":"wide","className":"alignwide gutenberg-landing\u002d\u002dfeatures-grid"} -->
-<ul class="wp-block-gallery alignwide columns-4 is-cropped gutenberg-landing--features-grid"><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Plugin-1-1.gif" alt=""/><figcaption>Do more with fewer plugins.</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Layout-3.gif" alt=""/><figcaption>Create modern, multimedia-heavy layouts.</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Devices-1-1.gif" alt=""/><figcaption>Work across all screen sizes and devices.</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Visual-1.gif" alt=""/><figcaption>Trust that your editor looks like your website.</figcaption></figure></li></ul>
-<!-- /wp:gallery -->
-
-<!-- wp:spacer -->
-<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
-<!-- /wp:spacer -->
-
-<!-- wp:wporg/download-button -->
-<div class="wp-block-wporg-download-button wp-block-button aligncenter"><a class="wp-block-button__link has-background has-strong-blue-background-color" href="https://wordpress.org/plugins/gutenberg/" style="background-color:rgb(0,115,170)">Download Gutenberg Today</a></div>
-<!-- /wp:wporg/download-button -->
-
-<!-- wp:paragraph {"align":"center","fontSize":"small","className":"gutenberg-landing\u002d\u002dbutton-disclaimer"} -->
-<p style="text-align:center" class="has-small-font-size gutenberg-landing--button-disclaimer"><em>Gutenberg is available as a plugin now, and soon by default in version 5.0 of WordPress. The <a href="https://wordpress.org/plugins/classic-editor/">classic editor</a> will be available as a plugin if needed.</em></p>
-<!-- /wp:paragraph -->
-
-<!-- wp:spacer -->
-<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
-<!-- /wp:spacer -->
-
-<!-- wp:heading {"align":"left"} -->
-<h2 style="text-align:left">Meet your new best friends, Blocks</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph {"align":"left"} -->
-<p style="text-align:left">Blocks are a great new tool for building engaging content. With blocks, you can insert, rearrange, and style multimedia content with very little technical knowledge. Instead of using custom code, you can add a block and focus on your content.</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:image {"id":358} -->
-<figure class="wp-block-image"><img src="https://wordpress.org/gutenberg/files/2018/07/Insert-Block-2-1.gif" alt="" class="wp-image-358"/></figure>
-<!-- /wp:image -->
-
-<!-- wp:paragraph {"align":"left"} -->
-<p style="text-align:left">Without being an expert developer, you can build your own custom posts and pages. Here’s a selection of the default blocks included with Gutenberg:</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:gallery {"ids":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"columns":8,"align":"full","className":"alignfull"} -->
-<ul class="wp-block-gallery alignfull columns-8 is-cropped"><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon.png" alt=""/><figcaption>Paragraph</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Heading.png" alt=""/><figcaption>Heading</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Subheading.png" alt=""/><figcaption>Subheading</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Quote.png" alt=""/><figcaption>Quote</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Image.png" alt=""/><figcaption>Image</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Gallery.png" alt=""/><figcaption>Gallery</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Cover-Image.png" alt=""/><figcaption>Cover Image</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Video.png" alt=""/><figcaption>Video</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Audio.png" alt=""/><figcaption>Audio</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Column.png" alt=""/><figcaption>Columns</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-File.png" alt=""/><figcaption>File</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Code.png" alt=""/><figcaption>Code</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-List.png" alt=""/><figcaption>List</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Button.png" alt=""/><figcaption>Button</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-Embeds.png" alt=""/><figcaption>Embeds</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="https://wordpress.org/gutenberg/files/2018/07/Block-Icon-More.png" alt=""/><figcaption>More</figcaption></figure></li></ul>
-<!-- /wp:gallery -->
-
-<!-- wp:spacer -->
-<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
-<!-- /wp:spacer -->
-
-<!-- wp:heading {"align":"left"} -->
-<h2 style="text-align:left">Be your own builder</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph {"align":"left"} -->
-<p style="text-align:left">A single block is nice—reliable, clear, distinct. Discover the flexibility to use media and content, side by side, driven by your vision.</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:image {"id":98363} -->
-<figure class="wp-block-image"><img src="https://wordpress.org/gutenberg/files/2018/08/Builder.gif" alt="" class="wp-image-98363"/></figure>
-<!-- /wp:image -->
-
-<!-- wp:spacer -->
-<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
-<!-- /wp:spacer -->
-
-<!-- wp:heading {"align":"left"} -->
-<h2 style="text-align:left">Gutenberg ❤️ Developers</h2>
-<!-- /wp:heading -->
-
-<!-- wp:columns {"className":"gutenberg-landing\u002d\u002ddevelopers-columns"} -->
-<div class="wp-block-columns has-2-columns gutenberg-landing--developers-columns"><!-- wp:column -->
-<div class="wp-block-column"><!-- wp:paragraph {"align":"left"} -->
-<p style="text-align:left"><strong>Built with modern technology.</strong></p>
-<!-- /wp:paragraph -->
-
-<!-- wp:paragraph {"align":"left"} -->
-<p style="text-align:left">Gutenberg was developed on GitHub using the WordPress REST API, JavaScript, and React.</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:paragraph {"align":"left","fontSize":"small"} -->
-<p style="text-align:left" class="has-small-font-size"><a href="https://wordpress.org/gutenberg/handbook/language/">Learn more</a></p>
-<!-- /wp:paragraph --></div>
-<!-- /wp:column -->
-
-<!-- wp:column -->
-<div class="wp-block-column"><!-- wp:paragraph {"align":"left"} -->
-<p style="text-align:left"><strong>Designed for compatibility.</strong></p>
-<!-- /wp:paragraph -->
-
-<!-- wp:paragraph {"align":"left"} -->
-<p style="text-align:left">We recommend migrating features to blocks, but support for existing WordPress functionality remains. There will be transition paths for shortcodes, meta-boxes, and Custom Post Types.</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:paragraph {"align":"left","fontSize":"small"} -->
-<p style="text-align:left" class="has-small-font-size"><a href="https://wordpress.org/gutenberg/handbook/reference/faq/">Learn more</a></p>
-<!-- /wp:paragraph --></div>
-<!-- /wp:column --></div>
-<!-- /wp:columns -->
-
-<!-- wp:spacer -->
-<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
-<!-- /wp:spacer -->
-
-<!-- wp:heading {"align":"left"} -->
-<h2 style="text-align:left">The editor is just the beginning</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph {"align":"left"} -->
-<p style="text-align:left">Gutenberg is more than an editor. It’s also the foundation that’ll revolutionize customization and site building in WordPress.</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:quote {"align":"left","className":"is-style-large"} -->
-<blockquote style="text-align:left" class="wp-block-quote is-style-large"><p>"This will make running your own blog a viable alternative again."</p><cite>— <a href="https://twitter.com/azumbrunnen_/status/1019347243084800005">Adrian Zumbrunnen</a></cite></blockquote>
-<!-- /wp:quote -->
-
-<!-- wp:quote {"align":"left","className":"is-style-large"} -->
-<blockquote style="text-align:left" class="wp-block-quote is-style-large"><p>"The web up until this point has been confined to some sort of rectangular screen. But that is not how it’s going to be. Gutenberg has the potential of moving us into the next time."</p><cite>— <a href="https://wordpress.tv/2017/12/10/morten-rand-hendriksen-gutenberg-and-the-wordpress-of-tomorrow/">Morten Rand-Hendriksen</a></cite></blockquote>
-<!-- /wp:quote -->
-
-<!-- wp:quote {"align":"left","className":"is-style-large"} -->
-<blockquote style="text-align:left" class="wp-block-quote is-style-large"><p>"The Gutenberg editor has some great assets that could genuinely help people to write better texts."</p><cite>— <a href="https://yoast.com/writing-with-gutenberg/">Marieke van de Rakt</a></cite></blockquote>
-<!-- /wp:quote -->
-
-<!-- wp:spacer -->
-<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
-<!-- /wp:spacer -->
-
-<!-- wp:wporg/download-button -->
-<div class="wp-block-wporg-download-button wp-block-button aligncenter"><a class="wp-block-button__link has-background has-strong-blue-background-color" href="https://wordpress.org/plugins/gutenberg/" style="background-color:rgb(0,115,170)">Download Gutenberg Today</a></div>
-<!-- /wp:wporg/download-button -->
-
-<!-- wp:paragraph {"align":"center","fontSize":"small","className":"gutenberg-landing\u002d\u002dbutton-disclaimer"} -->
-<p style="text-align:center" class="has-small-font-size gutenberg-landing--button-disclaimer"><em>Gutenberg is available as a plugin today, and will be included in version 5.0 of WordPress. The <a href="https://wordpress.org/plugins/classic-editor/">classic editor</a> will be available as a plugin if needed.</em></p>
-<!-- /wp:paragraph -->
-
-<!-- wp:spacer -->
-<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
-<!-- /wp:spacer -->
-
-<!-- wp:heading {"align":"left"} -->
-<h2 style="text-align:left">Dig in deeper</h2>
-<!-- /wp:heading -->
-
<!-- wp:list -->
-<ul><li><a href="https://make.wordpress.org/core/2017/01/17/editor-technical-overview">Gutenberg Editor Technical Overview</a></li><li><a href="https://wordpress.org/gutenberg/handbook/reference/design-principles/">Gutenberg Design Principles</a></li><li><a href="https://make.wordpress.org/core/tag/gutenberg/">Development updates on make.wordpress.org</a></li><li><a href="https://wordpress.tv/?s=gutenberg">WordPress.tv Talks about Gutenberg</a></li><li><a href="https://wordpress.org/gutenberg/handbook/reference/faq/">FAQs</a></li></ul>
+<ul><li>lin</li><li>asdf</li><li>e1</li></ul>
<!-- /wp:list -->
+<!-- wp:paragraph -->
+<p></p>
+<!-- /wp:paragraph -->
`;
diff --git a/src/block-management/block-manager.js b/src/block-management/block-manager.js
index 1c284bf8..f827ad37 100644
--- a/src/block-management/block-manager.js
+++ b/src/block-management/block-manager.js
@@ -265,7 +265,7 @@ export class BlockManager extends React.Component<PropsType, StateType> {
renderItem={ this.renderItem }
shouldPreventAutomaticScroll={ this.shouldFlatListPreventAutomaticScroll }
title={ this.props.title }
- ListHeaderComponent={ this.renderHeader }
+ // ListHeaderComponent={ this.renderHeader }
ListEmptyComponent={ this.renderDefaultBlockAppender }
/>
<SafeAreaView>
diff --git a/src/globals.js b/src/globals.js
index f807c18c..4f70a8c7 100644
--- a/src/globals.js
+++ b/src/globals.js
@@ -26,6 +26,16 @@ import { createElement } from '@wordpress/element';
*/
import './jsdom-patches';
+//import MessageQueue from 'react-native/Libraries/BatchedBridge/MessageQueue';
+//
+// to log all events
+//const spyFunction = ( msg ) => {
+// // eslint-disable-next-line no-console
+// console.log( msg );
+//};
+//
+//MessageQueue.spy( spyFunction );
+
global.wp = {
element: {
createElement, // load the element creation function, needed by Gutenberg-web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment