Skip to content

Commit 45a94eb

Browse files
committed
Merge branch 'trunk' into fix/redrawing-of-placeholder
2 parents 2f913c3 + 6355137 commit 45a94eb

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

media-placeholders/src/main/java/org/wordpress/aztec/placeholders/PlaceholderManager.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,22 @@ class PlaceholderManager(
117117
return drawable
118118
}
119119

120-
private suspend fun updateAllBelowSelection(selectionStart: Int) {
121-
positionToId.filter {
122-
it.elementPosition >= selectionStart - 1
123-
}.forEach {
120+
/**
121+
* Call this method to reload all the placeholders
122+
*/
123+
suspend fun reloadAllPlaceholders() {
124+
positionToId.forEach {
124125
insertContentOverSpanWithId(it.uuid)
125126
}
126127
}
127128

129+
/**
130+
* Call this method to relaod a placeholder with UUID
131+
*/
132+
suspend fun refreshWithUuid(uuid: String) {
133+
insertContentOverSpanWithId(uuid)
134+
}
135+
128136
private suspend fun insertContentOverSpanWithId(uuid: String) {
129137
var aztecAttributes: AztecAttributes? = null
130138
val predicate = object : AztecText.AttributePredicate {
@@ -221,7 +229,7 @@ class PlaceholderManager(
221229
*/
222230
override fun onContentChanged() {
223231
launch {
224-
updateAllBelowSelection(aztecText.selectionStart)
232+
reloadAllPlaceholders()
225233
}
226234
}
227235

0 commit comments

Comments
 (0)