Skip to content

Commit

Permalink
fix remove all embeds for multiple embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
marwoodandrew committed Aug 2, 2023
1 parent aa011a7 commit c5d76f7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions superdesk/editor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def insert(self, index, value):
self._mapping[value.key] = value.data

def clear(self):
for idx, kk in enumerate(self._ranges):
del self[kk.get("key")]
for idx, _range in enumerate(self._ranges):
del self[idx]


class Block:
Expand Down
32 changes: 31 additions & 1 deletion tests/publish/formatters/email_formatter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,24 @@ def test_remove_embedded_content(self):
"entityRanges": [{"offset": 0, "length": 1, "key": 0}],
"data": {},
},
{
"key": "8e23v",
"text": " ",
"type": "atomic",
"depth": 0,
"inlineStyleRanges": [],
"entityRanges": [{"offset": 0, "length": 1, "key": 1}],
"data": {},
},
{
"key": "an34p",
"text": " ",
"type": "atomic",
"depth": 0,
"inlineStyleRanges": [],
"entityRanges": [{"offset": 0, "length": 1, "key": 2}],
"data": {},
},
{
"key": "ambpd",
"text": "post amble",
Expand All @@ -378,7 +396,19 @@ def test_remove_embedded_content(self):
"data": {},
},
],
"entityMap": {"0": {"type": "MEDIA", "mutability": "MUTABLE", "data": {"media": {}}}},
"entityMap": {
"0": {"type": "MEDIA", "mutability": "MUTABLE", "data": {"media": {}}},
"1": {
"type": "EMBED",
"mutability": "MUTABLE",
"data": {"data": {"html": "<blockquote></blockquote>"}},
},
"2": {
"type": "EMBED",
"mutability": "MUTABLE",
"data": {"data": {"html": "<blockquote></blockquote>"}},
},
},
}
]
}
Expand Down

0 comments on commit c5d76f7

Please sign in to comment.