|
|
|
@ -177,21 +177,22 @@ class QuillRawEditorState extends EditorState |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (controller.copiedImageUrl != null) { |
|
|
|
|
// When image copied internally in the editor |
|
|
|
|
final copiedImageUrl = controller.copiedImageUrl; |
|
|
|
|
if (copiedImageUrl != null) { |
|
|
|
|
final index = textEditingValue.selection.baseOffset; |
|
|
|
|
final length = textEditingValue.selection.extentOffset - index; |
|
|
|
|
final copied = controller.copiedImageUrl!; |
|
|
|
|
controller.replaceText( |
|
|
|
|
index, |
|
|
|
|
length, |
|
|
|
|
BlockEmbed.image(copied.url), |
|
|
|
|
BlockEmbed.image(copiedImageUrl.url), |
|
|
|
|
null, |
|
|
|
|
); |
|
|
|
|
if (copied.styleString.isNotEmpty) { |
|
|
|
|
if (copiedImageUrl.styleString.isNotEmpty) { |
|
|
|
|
controller.formatText( |
|
|
|
|
getEmbedNode(controller, index + 1).offset, |
|
|
|
|
1, |
|
|
|
|
StyleAttribute(copied.styleString), |
|
|
|
|
StyleAttribute(copiedImageUrl.styleString), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
controller.copiedImageUrl = null; |
|
|
|
@ -206,17 +207,19 @@ class QuillRawEditorState extends EditorState |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: Bug, Doesn't replace the selected text, it just add a new one |
|
|
|
|
final clipboard = SystemClipboard.instance; |
|
|
|
|
|
|
|
|
|
final reader = await ClipboardReader.readClipboard(); |
|
|
|
|
if (clipboard != null) { |
|
|
|
|
// TODO: Bug, Doesn't replace the selected text, it just add a new one |
|
|
|
|
final reader = await clipboard.read(); |
|
|
|
|
if (reader.canProvide(Formats.htmlText)) { |
|
|
|
|
final html = await reader.readValue(Formats.htmlText); |
|
|
|
|
if (html == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
final deltaFromCliboard = Document.fromHtml(html); |
|
|
|
|
final deltaFromClipboard = Document.fromHtml(html); |
|
|
|
|
var newDelta = Delta(); |
|
|
|
|
newDelta = newDelta.compose(deltaFromCliboard); |
|
|
|
|
newDelta = newDelta.compose(deltaFromClipboard); |
|
|
|
|
if (!controller.document.isEmpty()) { |
|
|
|
|
newDelta = newDelta.compose(controller.document.toDelta()); |
|
|
|
|
} |
|
|
|
@ -247,6 +250,7 @@ class QuillRawEditorState extends EditorState |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Snapshot the input before using `await`. |
|
|
|
|
// See https://github.com/flutter/flutter/issues/11427 |
|
|
|
@ -279,7 +283,8 @@ class QuillRawEditorState extends EditorState |
|
|
|
|
|
|
|
|
|
final onImagePaste = widget.configurations.onImagePaste; |
|
|
|
|
if (onImagePaste != null) { |
|
|
|
|
final reader = await ClipboardReader.readClipboard(); |
|
|
|
|
if (clipboard != null) { |
|
|
|
|
final reader = await clipboard.read(); |
|
|
|
|
if (!reader.canProvide(Formats.png)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -300,6 +305,7 @@ class QuillRawEditorState extends EditorState |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Select the entire text value. |
|
|
|
|
@override |
|
|
|
|