Skip to content

Commit

Permalink
[Quaaantum] Added ability to create a custom copy handler
Browse files Browse the repository at this point in the history
  • Loading branch information
quaaantumdev authored and kferstl committed May 14, 2024
1 parent 71fb05a commit c434850
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions super_editor/lib/src/document_operations/selection_operations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -621,12 +621,24 @@ bool selectAll(Document document, ValueNotifier<DocumentSelection?> selection) {
return true;
}

typedef SuperEditorCopyHandler = void Function(
Document document, DocumentSelection selection);
SuperEditorCopyHandler? _customCopyHandler;
void configureCustomSuperEditorCopyHandler(SuperEditorCopyHandler copyHandler) {
_customCopyHandler = copyHandler;
}

/// Serializes the current selection to plain text, and adds it to the
/// clipboard.
void copy({
required Document document,
required DocumentSelection selection,
}) {
final customCopyHandler = _customCopyHandler;
if (customCopyHandler != null) {
customCopyHandler(document, selection);
return;
}
final textToCopy = _textInSelection(
document: document,
documentSelection: selection,
Expand Down

0 comments on commit c434850

Please sign in to comment.