@@ -102,7 +102,6 @@ import org.wordpress.aztec.watchers.DeleteMediaElementWatcherAPI25AndHigher
102102import org.wordpress.aztec.watchers.DeleteMediaElementWatcherPreAPI25
103103import org.wordpress.aztec.watchers.EndOfBufferMarkerAdder
104104import org.wordpress.aztec.watchers.EndOfParagraphMarkerAdder
105- import org.wordpress.aztec.watchers.EnterPressedWatcher
106105import org.wordpress.aztec.watchers.FullWidthImageElementWatcher
107106import org.wordpress.aztec.watchers.InlineTextWatcher
108107import org.wordpress.aztec.watchers.ParagraphBleedAdjuster
@@ -320,7 +319,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
320319 }
321320
322321 interface OnAztecKeyListener {
323- fun onEnterKey () : Boolean
322+ fun onEnterKey (text : Spannable , firedAfterTextChanged : Boolean , selStart : Int , selEnd : Int ) : Boolean
324323 fun onBackspaceKey () : Boolean
325324 }
326325
@@ -521,7 +520,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
521520 if (event.action == KeyEvent .ACTION_DOWN && event.keyCode == KeyEvent .KEYCODE_ENTER ) {
522521 // Check if the external listener has consumed the enter pressed event
523522 // In that case stop the execution
524- if (onAztecKeyListener?.onEnterKey() == true ) {
523+ if (onAztecKeyListener?.onEnterKey(text, false , 0 , 0 ) == true ) {
525524 return true
526525 }
527526 }
@@ -557,11 +556,6 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
557556 }
558557
559558 private fun install () {
560- // Keep the enter pressed watcher at the beginning of the watchers list.
561- // We want to intercept Enter.key as soon as possible, and before other listeners start modifying the text.
562- // Also note that this Watchers, when the AztecKeyListener is set, keep hold a copy of the content in the editor.
563- EnterPressedWatcher .install(this )
564-
565559 ParagraphBleedAdjuster .install(this )
566560 ParagraphCollapseAdjuster .install(this )
567561
@@ -1239,15 +1233,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
12391233 // returns regular or "calypso" html depending on the mode
12401234 // default behavior returns HTML from this text
12411235 fun toHtml (withCursorTag : Boolean = false): String {
1242- val html = toPlainHtml(withCursorTag)
1243-
1244- if (isInCalypsoMode) {
1245- // calypso format is a mix of newline characters and html
1246- // paragraphs and line breaks are added on server, from newline characters
1247- return Format .addSourceEditorFormatting(html, true )
1248- } else {
1249- return html
1250- }
1236+ return toHtml(text, withCursorTag)
12511237 }
12521238
12531239 // general function accepts any Spannable and converts it to regular or "calypso" html
@@ -1267,15 +1253,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
12671253 // platform agnostic HTML
12681254 // default behavior returns HTML from this text
12691255 fun toPlainHtml (withCursorTag : Boolean = false): String {
1270- return if (Looper .myLooper() != Looper .getMainLooper()) {
1271- runBlocking {
1272- withContext(Dispatchers .Main ) {
1273- parseHtml(text, withCursorTag)
1274- }
1275- }
1276- } else {
1277- parseHtml(text, withCursorTag)
1278- }
1256+ return toPlainHtml(text, withCursorTag)
12791257 }
12801258
12811259 // general function accepts any Spannable and converts it to platform agnostic HTML
@@ -1295,7 +1273,6 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
12951273 val parser = AztecParser (plugins)
12961274 val output: SpannableStringBuilder
12971275 try {
1298- // output = SpannableStringBuilder(text)
12991276 output = SpannableStringBuilder (content)
13001277 } catch (e: Exception ) {
13011278 // FIXME: Remove this log once we've data to replicate the issue, and fix it in some way.
0 commit comments