clipboardSelection method
Implementation
@experimental
bool clipboardSelection(bool copy) {
copiedImageUrl = null;
/// Get the text for the selected region and expand the content of Embedded objects.
_pastePlainText = document.getPlainText(
selection.start,
selection.end - selection.start,
includeEmbeds: true,
);
/// Get the internal representation so it can be pasted into a QuillEditor with style retained.
_pasteStyleAndEmbed = getAllIndividualSelectionStylesAndEmbed();
/// Get the deltas for the selection so they can be pasted into a QuillEditor with styles and embeds retained.
_pasteDelta = document.toDelta().slice(selection.start, selection.end);
if (!selection.isCollapsed) {
Clipboard.setData(ClipboardData(text: _pastePlainText));
if (!copy) {
if (readOnly) return false;
final sel = selection;
replaceText(sel.start, sel.end - sel.start, '',
TextSelection.collapsed(offset: sel.start));
}
return true;
}
return false;
}