Edit book: When changing a paragraph to a heading if the cursor is adjacent to a paragraph tag but not inside any tags other than body, use the adjacent tag

This commit is contained in:
Kovid Goyal 2021-09-24 10:55:27 +05:30
parent 932c37d9e1
commit 95fc272b5b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -422,6 +422,14 @@ class Smarts(NullSmarts):
tag = find_closest_containing_block_tag(block, offset)
if tag is not None:
if tag.name == 'body':
ntag = find_closest_containing_block_tag(block, offset + 1)
if ntag is not None and ntag.name != 'body':
tag = ntag
elif offset > 0:
ntag = find_closest_containing_block_tag(block, offset - 1)
if ntag is not None and ntag.name != 'body':
tag = ntag
closing_tag = find_closing_tag(tag)
if closing_tag is None:
return error_dialog(editor, _('Invalid HTML'), _(