|
|
|
@ -4,6 +4,7 @@ import 'package:collection/collection.dart'; |
|
|
|
|
|
|
|
|
|
import '../../../../quill_delta.dart'; |
|
|
|
|
import '../../common/structs/offset_value.dart'; |
|
|
|
|
import '../../editor/config/editor_configurations.dart'; |
|
|
|
|
import '../../editor/embed/embed_editor_builder.dart'; |
|
|
|
|
import '../attribute.dart'; |
|
|
|
|
import '../style.dart'; |
|
|
|
@ -511,25 +512,35 @@ base class Line extends QuillContainer<Leaf?> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Returns plain text within the specified text range. |
|
|
|
|
String getPlainText(int offset, int len) { |
|
|
|
|
String getPlainText(int offset, int len, |
|
|
|
|
[QuillEditorConfigurations? config]) { |
|
|
|
|
final plainText = StringBuffer(); |
|
|
|
|
_getPlainText(offset, len, plainText); |
|
|
|
|
_getPlainText(offset, len, plainText, config); |
|
|
|
|
return plainText.toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int _getNodeText(Leaf node, StringBuffer buffer, int offset, int remaining) { |
|
|
|
|
final text = node.toPlainText(); |
|
|
|
|
int _getNodeText(Leaf node, StringBuffer buffer, int offset, int remaining, |
|
|
|
|
QuillEditorConfigurations? config) { |
|
|
|
|
final text = |
|
|
|
|
node.toPlainText(config?.embedBuilders, config?.unknownEmbedBuilder); |
|
|
|
|
if (text == Embed.kObjectReplacementCharacter) { |
|
|
|
|
buffer.write(Embed.kObjectReplacementCharacter); |
|
|
|
|
return remaining - node.length; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Text for clipboard will expand the content of Embed nodes |
|
|
|
|
if (node is Embed && config != null) { |
|
|
|
|
buffer.write(text); |
|
|
|
|
return remaining - 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final end = math.min(offset + remaining, text.length); |
|
|
|
|
buffer.write(text.substring(offset, end)); |
|
|
|
|
return remaining - (end - offset); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int _getPlainText(int offset, int len, StringBuffer plainText) { |
|
|
|
|
int _getPlainText(int offset, int len, StringBuffer plainText, |
|
|
|
|
QuillEditorConfigurations? config) { |
|
|
|
|
var len0 = len; |
|
|
|
|
final data = queryChild(offset, false); |
|
|
|
|
var node = data.node as Leaf?; |
|
|
|
@ -540,11 +551,12 @@ base class Line extends QuillContainer<Leaf?> { |
|
|
|
|
plainText.write('\n'); |
|
|
|
|
len0 -= 1; |
|
|
|
|
} else { |
|
|
|
|
len0 = _getNodeText(node, plainText, offset - node.offset, len0); |
|
|
|
|
len0 = |
|
|
|
|
_getNodeText(node, plainText, offset - node.offset, len0, config); |
|
|
|
|
|
|
|
|
|
while (!node!.isLast && len0 > 0) { |
|
|
|
|
node = node.next as Leaf; |
|
|
|
|
len0 = _getNodeText(node, plainText, 0, len0); |
|
|
|
|
len0 = _getNodeText(node, plainText, 0, len0, config); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (len0 > 0) { |
|
|
|
@ -555,7 +567,7 @@ base class Line extends QuillContainer<Leaf?> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (len0 > 0 && nextLine != null) { |
|
|
|
|
len0 = nextLine!._getPlainText(0, len0, plainText); |
|
|
|
|
len0 = nextLine!._getPlainText(0, len0, plainText, config); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|