Skip to content

Commit c2b3b25

Browse files
authored
Merge pull request #745 from wordpress-mobile/fix/paste-hash-calculation
Added isInit flag to only calculate initial content hash when initializing
2 parents 83d0fe6 + fbfe28c commit c2b3b25

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
10121012
return cursorPosition
10131013
}
10141014

1015-
open fun fromHtml(source: String) {
1015+
open fun fromHtml(source: String, isInit: Boolean = true) {
10161016
val builder = SpannableStringBuilder()
10171017
val parser = AztecParser(plugins)
10181018

@@ -1037,7 +1037,9 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
10371037

10381038
setSelection(cursorPosition)
10391039

1040-
initialEditorContentParsedSHA256 = calculateInitialHTMLSHA(toPlainHtml(false), initialEditorContentParsedSHA256)
1040+
if (isInit) {
1041+
initialEditorContentParsedSHA256 = calculateInitialHTMLSHA(toPlainHtml(false), initialEditorContentParsedSHA256)
1042+
}
10411043

10421044
loadImages()
10431045
loadVideos()
@@ -1400,7 +1402,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
14001402
val oldHtml = toPlainHtml().replace("<aztec_cursor>", "")
14011403
val newHtml = oldHtml.replace(Constants.REPLACEMENT_MARKER_STRING, textToPaste + "<" + AztecCursorSpan.AZTEC_CURSOR_TAG + ">")
14021404

1403-
fromHtml(newHtml)
1405+
fromHtml(newHtml, false)
14041406
inlineFormatter.joinStyleSpans(0, length())
14051407
}
14061408
}

0 commit comments

Comments
 (0)