Skip to content

Commit 55244dc

Browse files
committed
Method for setting parsed content.
1 parent f749d3b commit 55244dc

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,38 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
15401540
return cursorPosition
15411541
}
15421542

1543+
open fun fromParsedContent(spannedText: Spanned, isInit: Boolean = true){
1544+
val builder = SpannableStringBuilder()
1545+
1546+
builder.append(spannedText)
1547+
1548+
Format.preProcessSpannedText(builder, isInCalypsoMode)
1549+
1550+
switchToAztecStyle(builder, 0, builder.length)
1551+
disableTextChangedListener()
1552+
1553+
builder.getSpans(0, builder.length, AztecDynamicImageSpan::class.java).forEach {
1554+
it.textView = WeakReference(this)
1555+
}
1556+
1557+
val cursorPosition = consumeCursorPosition(builder)
1558+
setSelection(0)
1559+
1560+
setTextKeepState(builder)
1561+
enableTextChangedListener()
1562+
1563+
setSelection(cursorPosition)
1564+
1565+
if (isInit) {
1566+
initialEditorContentParsedSHA256 =
1567+
calculateInitialHTMLSHA(toPlainHtml(false), initialEditorContentParsedSHA256)
1568+
}
1569+
1570+
loadImages()
1571+
loadVideos()
1572+
mediaCallback?.mediaLoadingStarted()
1573+
}
1574+
15431575
open fun fromHtml(source: String, isInit: Boolean = true) {
15441576
val builder = SpannableStringBuilder()
15451577
val parser = AztecParser(alignmentRendering, plugins)

0 commit comments

Comments
 (0)