Skip to content

Commit 2f7e982

Browse files
committed
Merge branch 'trunk' into feature/implement-merging-of-placeholders
2 parents 6919dd3 + 6355137 commit 2f7e982

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
@@ -159,14 +159,22 @@ class PlaceholderManager(
159159
return drawable
160160
}
161161

162-
private suspend fun updateAllBelowSelection(selectionStart: Int) {
163-
positionToId.filter {
164-
it.elementPosition >= selectionStart - 1
165-
}.forEach {
162+
/**
163+
* Call this method to reload all the placeholders
164+
*/
165+
suspend fun reloadAllPlaceholders() {
166+
positionToId.forEach {
166167
insertContentOverSpanWithId(it.uuid)
167168
}
168169
}
169170

171+
/**
172+
* Call this method to relaod a placeholder with UUID
173+
*/
174+
suspend fun refreshWithUuid(uuid: String) {
175+
insertContentOverSpanWithId(uuid)
176+
}
177+
170178
private suspend fun insertContentOverSpanWithId(uuid: String) {
171179
var aztecAttributes: AztecAttributes? = null
172180
val predicate = object : AztecText.AttributePredicate {
@@ -263,7 +271,7 @@ class PlaceholderManager(
263271
*/
264272
override fun onContentChanged() {
265273
launch {
266-
updateAllBelowSelection(aztecText.selectionStart)
274+
reloadAllPlaceholders()
267275
}
268276
}
269277

0 commit comments

Comments
 (0)