Skip to content

Commit

Permalink
[super_editor_markdown] Fix compilation error (#2406)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelosilvestre authored Nov 30, 2024
1 parent d5d0f8d commit 4df6c25
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions super_editor_markdown/lib/src/super_editor_paste_markdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,19 @@ Future<void> pasteMarkdown({
required Document document,
required DocumentComposer composer,
}) async {
DocumentPosition pastePosition = composer.selection!.extent;

// Delete all currently selected content.
if (!composer.selection!.isCollapsed) {
pastePosition = CommonEditorOperations.getDocumentPositionAfterExpandedDeletion(
final pastePosition = CommonEditorOperations.getDocumentPositionAfterExpandedDeletion(
document: document,
selection: composer.selection!,
);

if (pastePosition == null) {
// A null pastePosition means that the selection can't be deleted. This might happen
// when the selection contains only non-deletable nodes. Therefore, we cannot paste.
return;
}

// Delete the selected content.
editor.execute([
DeleteContentRequest(documentRange: composer.selection!),
Expand All @@ -67,7 +71,7 @@ Future<void> pasteMarkdown({
editor.execute([
PasteStructuredContentEditorRequest(
content: deserializedMarkdown,
pastePosition: pastePosition,
pastePosition: composer.selection!.extent,
),
]);
}

0 comments on commit 4df6c25

Please sign in to comment.