@@ -246,6 +246,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
246246 var commentsVisible = resources.getBoolean(R .bool.comments_visible)
247247
248248 var isInCalypsoMode = true
249+ var isInGutenbergMode = false
249250
250251 var consumeHistoryEvent: Boolean = false
251252
@@ -343,6 +344,10 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
343344 isInCalypsoMode = isCompatibleWithCalypso
344345 }
345346
347+ fun setGutenbergMode (isCompatibleWithGutenberg : Boolean ) {
348+ isInGutenbergMode = isCompatibleWithGutenberg
349+ }
350+
346351 @SuppressLint(" ResourceType" )
347352 private fun init (attrs : AttributeSet ? ) {
348353 disableTextChangedListener()
@@ -860,6 +865,10 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
860865 if (! isViewInitialized) return
861866
862867 if (isOnSelectionListenerDisabled()) {
868+ if (isInGutenbergMode) {
869+ return
870+ }
871+
863872 enableOnSelectionListener()
864873 return
865874 }
@@ -1128,7 +1137,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
11281137 val parser = AztecParser (plugins)
11291138
11301139 var cleanSource = CleaningUtils .cleanNestedBoldTags(source)
1131- cleanSource = Format .removeSourceEditorFormatting(cleanSource, isInCalypsoMode)
1140+ cleanSource = Format .removeSourceEditorFormatting(cleanSource, isInCalypsoMode, isInGutenbergMode )
11321141 builder.append(parser.fromHtml(cleanSource, context))
11331142
11341143 Format .preProcessSpannedText(builder, isInCalypsoMode)
@@ -1538,7 +1547,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
15381547 }
15391548 }
15401549
1541- val html = Format .removeSourceEditorFormatting(parser.toHtml(output), isInCalypsoMode)
1550+ val html = Format .removeSourceEditorFormatting(parser.toHtml(output), isInCalypsoMode, isInGutenbergMode )
15421551
15431552 val clipboard = context.getSystemService(Context .CLIPBOARD_SERVICE ) as android.content.ClipboardManager
15441553 clipboard.primaryClip = ClipData .newHtmlText(" aztec" , output.toString(), html)
0 commit comments