Skip to content

Commit f0c7abd

Browse files
committed
Preserve correct cursor position after pasting
1 parent d6c8254 commit f0c7abd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,8 @@ class AztecText : AppCompatAutoCompleteTextView, TextWatcher, UnknownHtmlSpan.On
10411041
if (clip.itemCount > 0) {
10421042
val textToPaste = clip.getItemAt(0).coerceToHtmlText(context, AztecParser(plugins))
10431043

1044-
val oldHtml = toPlainHtml()
1045-
val newHtml = oldHtml.replace(Constants.REPLACEMENT_MARKER_STRING, textToPaste)
1044+
val oldHtml = toPlainHtml().replace("<aztec_cursor>", "")
1045+
val newHtml = oldHtml.replace(Constants.REPLACEMENT_MARKER_STRING, textToPaste + "<" + AztecCursorSpan.AZTEC_CURSOR_TAG + ">")
10461046

10471047
history.beforeTextChanged(toFormattedHtml())
10481048
fromHtml(newHtml)

0 commit comments

Comments
 (0)