Auto expand to paragraph on clear

This commit is contained in:
M66B 2020-11-17 21:55:02 +01:00
parent c5ca100680
commit bd9b1d5f93
1 changed files with 14 additions and 7 deletions

View File

@ -353,15 +353,22 @@ public class StyleHelper {
}
private boolean clear(MenuItem item) {
for (Object span : t.getSpans(s, e, Object.class))
int start = s;
int end = e;
// Expand to paragraph (block quotes)
if (end + 1 < t.length() && t.charAt(end) == '\n')
end++;
for (Object span : t.getSpans(start, end, Object.class))
if (!(span instanceof ImageSpan)) {
int start = t.getSpanStart(span);
int end = t.getSpanEnd(span);
int sstart = t.getSpanStart(span);
int send = t.getSpanEnd(span);
int flags = t.getSpanFlags(span);
if (start < s && end > s)
setSpan(t, span, start, s, flags, etBody.getContext());
if (start < e && end > e)
setSpan(t, span, e, end, flags, etBody.getContext());
if (sstart < start && send > start)
setSpan(t, span, sstart, start, flags, etBody.getContext());
if (sstart < end && send > end)
setSpan(t, span, end, send, flags, etBody.getContext());
t.removeSpan(span);
}