|
@@ -60,7 +60,8 @@ class RawEditor extends StatefulWidget {
|
|
|
this.embedBuilder,
|
|
|
) : assert(maxHeight == null || maxHeight > 0, 'maxHeight cannot be null'),
|
|
|
assert(minHeight == null || minHeight >= 0, 'minHeight cannot be null'),
|
|
|
- assert(maxHeight == null || minHeight == null || maxHeight >= minHeight),
|
|
|
+ assert(
|
|
|
+ maxHeight == null || minHeight == null || maxHeight >= minHeight),
|
|
|
showCursor = showCursor ?? true,
|
|
|
super(key: key);
|
|
|
|
|
@@ -111,7 +112,10 @@ abstract class EditorState extends State<RawEditor> {
|
|
|
}
|
|
|
|
|
|
class _RawEditorState extends EditorState
|
|
|
- with AutomaticKeepAliveClientMixin<RawEditor>, WidgetsBindingObserver, TickerProviderStateMixin<RawEditor>
|
|
|
+ with
|
|
|
+ AutomaticKeepAliveClientMixin<RawEditor>,
|
|
|
+ WidgetsBindingObserver,
|
|
|
+ TickerProviderStateMixin<RawEditor>
|
|
|
implements TextSelectionDelegate, TextInputClient {
|
|
|
final GlobalKey _editorKey = GlobalKey();
|
|
|
final List<TextEditingValue> _sentRemoteValues = [];
|
|
@@ -129,7 +133,8 @@ class _RawEditorState extends EditorState
|
|
|
bool _didAutoFocus = false;
|
|
|
bool _keyboardVisible = false;
|
|
|
DefaultStyles? _styles;
|
|
|
- final ClipboardStatusNotifier? _clipboardStatus = kIsWeb ? null : ClipboardStatusNotifier();
|
|
|
+ final ClipboardStatusNotifier? _clipboardStatus =
|
|
|
+ kIsWeb ? null : ClipboardStatusNotifier();
|
|
|
final LayerLink _toolbarLayerLink = LayerLink();
|
|
|
final LayerLink _startHandleLayerLink = LayerLink();
|
|
|
final LayerLink _endHandleLayerLink = LayerLink();
|
|
@@ -177,57 +182,78 @@ class _RawEditorState extends EditorState
|
|
|
downKey = key == LogicalKeyboardKey.arrowDown;
|
|
|
|
|
|
if ((rightKey || leftKey) && !(rightKey && leftKey)) {
|
|
|
- newSelection =
|
|
|
- _jumpToBeginOrEndOfWord(newSelection, wordModifier, leftKey, rightKey, plainText, lineModifier, shift);
|
|
|
+ newSelection = _jumpToBeginOrEndOfWord(newSelection, wordModifier,
|
|
|
+ leftKey, rightKey, plainText, lineModifier, shift);
|
|
|
}
|
|
|
|
|
|
if (downKey || upKey) {
|
|
|
- newSelection = _handleMovingCursorVertically(upKey, downKey, shift, selection, newSelection, plainText);
|
|
|
+ newSelection = _handleMovingCursorVertically(
|
|
|
+ upKey, downKey, shift, selection, newSelection, plainText);
|
|
|
}
|
|
|
|
|
|
if (!shift) {
|
|
|
- newSelection = _placeCollapsedSelection(selection, newSelection, leftKey, rightKey);
|
|
|
+ newSelection =
|
|
|
+ _placeCollapsedSelection(selection, newSelection, leftKey, rightKey);
|
|
|
}
|
|
|
|
|
|
widget.controller.updateSelection(newSelection, ChangeSource.LOCAL);
|
|
|
}
|
|
|
|
|
|
- TextSelection _placeCollapsedSelection(
|
|
|
- TextSelection selection, TextSelection newSelection, bool leftKey, bool rightKey) {
|
|
|
+ TextSelection _placeCollapsedSelection(TextSelection selection,
|
|
|
+ TextSelection newSelection, bool leftKey, bool rightKey) {
|
|
|
var newOffset = newSelection.extentOffset;
|
|
|
if (!selection.isCollapsed) {
|
|
|
if (leftKey) {
|
|
|
- newOffset =
|
|
|
- newSelection.baseOffset < newSelection.extentOffset ? newSelection.baseOffset : newSelection.extentOffset;
|
|
|
+ newOffset = newSelection.baseOffset < newSelection.extentOffset
|
|
|
+ ? newSelection.baseOffset
|
|
|
+ : newSelection.extentOffset;
|
|
|
} else if (rightKey) {
|
|
|
- newOffset =
|
|
|
- newSelection.baseOffset > newSelection.extentOffset ? newSelection.baseOffset : newSelection.extentOffset;
|
|
|
+ newOffset = newSelection.baseOffset > newSelection.extentOffset
|
|
|
+ ? newSelection.baseOffset
|
|
|
+ : newSelection.extentOffset;
|
|
|
}
|
|
|
}
|
|
|
return TextSelection.fromPosition(TextPosition(offset: newOffset));
|
|
|
}
|
|
|
|
|
|
TextSelection _handleMovingCursorVertically(
|
|
|
- bool upKey, bool downKey, bool shift, TextSelection selection, TextSelection newSelection, String plainText) {
|
|
|
- final originPosition = TextPosition(offset: upKey ? selection.baseOffset : selection.extentOffset);
|
|
|
+ bool upKey,
|
|
|
+ bool downKey,
|
|
|
+ bool shift,
|
|
|
+ TextSelection selection,
|
|
|
+ TextSelection newSelection,
|
|
|
+ String plainText) {
|
|
|
+ final originPosition = TextPosition(
|
|
|
+ offset: upKey ? selection.baseOffset : selection.extentOffset);
|
|
|
|
|
|
final child = getRenderEditor()!.childAtPosition(originPosition);
|
|
|
- final localPosition = TextPosition(offset: originPosition.offset - child.container.documentOffset);
|
|
|
+ final localPosition = TextPosition(
|
|
|
+ offset: originPosition.offset - child.container.documentOffset);
|
|
|
|
|
|
- var position = upKey ? child.getPositionAbove(localPosition) : child.getPositionBelow(localPosition);
|
|
|
+ var position = upKey
|
|
|
+ ? child.getPositionAbove(localPosition)
|
|
|
+ : child.getPositionBelow(localPosition);
|
|
|
|
|
|
if (position == null) {
|
|
|
- final sibling = upKey ? getRenderEditor()!.childBefore(child) : getRenderEditor()!.childAfter(child);
|
|
|
+ final sibling = upKey
|
|
|
+ ? getRenderEditor()!.childBefore(child)
|
|
|
+ : getRenderEditor()!.childAfter(child);
|
|
|
if (sibling == null) {
|
|
|
position = TextPosition(offset: upKey ? 0 : plainText.length - 1);
|
|
|
} else {
|
|
|
- final finalOffset = Offset(child.getOffsetForCaret(localPosition).dx,
|
|
|
- sibling.getOffsetForCaret(TextPosition(offset: upKey ? sibling.container.length - 1 : 0)).dy);
|
|
|
+ final finalOffset = Offset(
|
|
|
+ child.getOffsetForCaret(localPosition).dx,
|
|
|
+ sibling
|
|
|
+ .getOffsetForCaret(TextPosition(
|
|
|
+ offset: upKey ? sibling.container.length - 1 : 0))
|
|
|
+ .dy);
|
|
|
final siblingPosition = sibling.getPositionForOffset(finalOffset);
|
|
|
- position = TextPosition(offset: sibling.container.documentOffset + siblingPosition.offset);
|
|
|
+ position = TextPosition(
|
|
|
+ offset: sibling.container.documentOffset + siblingPosition.offset);
|
|
|
}
|
|
|
} else {
|
|
|
- position = TextPosition(offset: child.container.documentOffset + position.offset);
|
|
|
+ position = TextPosition(
|
|
|
+ offset: child.container.documentOffset + position.offset);
|
|
|
}
|
|
|
|
|
|
if (position.offset == newSelection.extentOffset) {
|
|
@@ -250,33 +276,47 @@ class _RawEditorState extends EditorState
|
|
|
return newSelection;
|
|
|
}
|
|
|
|
|
|
- TextSelection _jumpToBeginOrEndOfWord(TextSelection newSelection, bool wordModifier, bool leftKey, bool rightKey,
|
|
|
- String plainText, bool lineModifier, bool shift) {
|
|
|
+ TextSelection _jumpToBeginOrEndOfWord(
|
|
|
+ TextSelection newSelection,
|
|
|
+ bool wordModifier,
|
|
|
+ bool leftKey,
|
|
|
+ bool rightKey,
|
|
|
+ String plainText,
|
|
|
+ bool lineModifier,
|
|
|
+ bool shift) {
|
|
|
if (wordModifier) {
|
|
|
if (leftKey) {
|
|
|
final textSelection = getRenderEditor()!.selectWordAtPosition(
|
|
|
- TextPosition(offset: _previousCharacter(newSelection.extentOffset, plainText, false)));
|
|
|
+ TextPosition(
|
|
|
+ offset: _previousCharacter(
|
|
|
+ newSelection.extentOffset, plainText, false)));
|
|
|
return newSelection.copyWith(extentOffset: textSelection.baseOffset);
|
|
|
}
|
|
|
- final textSelection = getRenderEditor()!
|
|
|
- .selectWordAtPosition(TextPosition(offset: _nextCharacter(newSelection.extentOffset, plainText, false)));
|
|
|
+ final textSelection = getRenderEditor()!.selectWordAtPosition(
|
|
|
+ TextPosition(
|
|
|
+ offset:
|
|
|
+ _nextCharacter(newSelection.extentOffset, plainText, false)));
|
|
|
return newSelection.copyWith(extentOffset: textSelection.extentOffset);
|
|
|
} else if (lineModifier) {
|
|
|
if (leftKey) {
|
|
|
final textSelection = getRenderEditor()!.selectLineAtPosition(
|
|
|
- TextPosition(offset: _previousCharacter(newSelection.extentOffset, plainText, false)));
|
|
|
+ TextPosition(
|
|
|
+ offset: _previousCharacter(
|
|
|
+ newSelection.extentOffset, plainText, false)));
|
|
|
return newSelection.copyWith(extentOffset: textSelection.baseOffset);
|
|
|
}
|
|
|
final startPoint = newSelection.extentOffset;
|
|
|
if (startPoint < plainText.length) {
|
|
|
- final textSelection = getRenderEditor()!.selectLineAtPosition(TextPosition(offset: startPoint));
|
|
|
+ final textSelection = getRenderEditor()!
|
|
|
+ .selectLineAtPosition(TextPosition(offset: startPoint));
|
|
|
return newSelection.copyWith(extentOffset: textSelection.extentOffset);
|
|
|
}
|
|
|
return newSelection;
|
|
|
}
|
|
|
|
|
|
if (rightKey && newSelection.extentOffset < plainText.length) {
|
|
|
- final nextExtent = _nextCharacter(newSelection.extentOffset, plainText, true);
|
|
|
+ final nextExtent =
|
|
|
+ _nextCharacter(newSelection.extentOffset, plainText, true);
|
|
|
final distance = nextExtent - newSelection.extentOffset;
|
|
|
newSelection = newSelection.copyWith(extentOffset: nextExtent);
|
|
|
if (shift) {
|
|
@@ -286,7 +326,8 @@ class _RawEditorState extends EditorState
|
|
|
}
|
|
|
|
|
|
if (leftKey && newSelection.extentOffset > 0) {
|
|
|
- final previousExtent = _previousCharacter(newSelection.extentOffset, plainText, true);
|
|
|
+ final previousExtent =
|
|
|
+ _previousCharacter(newSelection.extentOffset, plainText, true);
|
|
|
final distance = newSelection.extentOffset - previousExtent;
|
|
|
newSelection = newSelection.copyWith(extentOffset: previousExtent);
|
|
|
if (shift) {
|
|
@@ -326,7 +367,9 @@ class _RawEditorState extends EditorState
|
|
|
var count = 0;
|
|
|
int? lastNonWhitespace;
|
|
|
for (final currentString in string.characters) {
|
|
|
- if (!includeWhitespace && !WHITE_SPACE.contains(currentString.characters.first.toString().codeUnitAt(0))) {
|
|
|
+ if (!includeWhitespace &&
|
|
|
+ !WHITE_SPACE.contains(
|
|
|
+ currentString.characters.first.toString().codeUnitAt(0))) {
|
|
|
lastNonWhitespace = count;
|
|
|
}
|
|
|
if (count + currentString.length >= index) {
|
|
@@ -337,7 +380,8 @@ class _RawEditorState extends EditorState
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- bool get hasConnection => _textInputConnection != null && _textInputConnection!.attached;
|
|
|
+ bool get hasConnection =>
|
|
|
+ _textInputConnection != null && _textInputConnection!.attached;
|
|
|
|
|
|
void openConnectionIfNeeded() {
|
|
|
if (!shouldCreateInputConnection) {
|
|
@@ -388,7 +432,8 @@ class _RawEditorState extends EditorState
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- final shouldRemember = textEditingValue.text != _lastKnownRemoteTextEditingValue!.text;
|
|
|
+ final shouldRemember =
|
|
|
+ textEditingValue.text != _lastKnownRemoteTextEditingValue!.text;
|
|
|
_lastKnownRemoteTextEditingValue = actualValue;
|
|
|
_textInputConnection!.setEditingState(actualValue);
|
|
|
if (shouldRemember) {
|
|
@@ -397,7 +442,8 @@ class _RawEditorState extends EditorState
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
- TextEditingValue? get currentTextEditingValue => _lastKnownRemoteTextEditingValue;
|
|
|
+ TextEditingValue? get currentTextEditingValue =>
|
|
|
+ _lastKnownRemoteTextEditingValue;
|
|
|
|
|
|
@override
|
|
|
AutofillScope? get currentAutofillScope => null;
|
|
@@ -429,7 +475,8 @@ class _RawEditorState extends EditorState
|
|
|
final text = value.text;
|
|
|
final cursorPosition = value.selection.extentOffset;
|
|
|
final diff = getDiff(oldText, text, cursorPosition);
|
|
|
- widget.controller.replaceText(diff.start, diff.deleted.length, diff.inserted, value.selection);
|
|
|
+ widget.controller.replaceText(
|
|
|
+ diff.start, diff.deleted.length, diff.inserted, value.selection);
|
|
|
}
|
|
|
|
|
|
@override
|
|
@@ -479,8 +526,11 @@ class _RawEditorState extends EditorState
|
|
|
super.build(context);
|
|
|
|
|
|
var _doc = widget.controller.document;
|
|
|
- if (_doc.isEmpty() && !widget.focusNode.hasFocus && widget.placeholder != null) {
|
|
|
- _doc = Document.fromJson(jsonDecode('[{"attributes":{"placeholder":true},"insert":"${widget.placeholder}\\n"}]'));
|
|
|
+ if (_doc.isEmpty() &&
|
|
|
+ !widget.focusNode.hasFocus &&
|
|
|
+ widget.placeholder != null) {
|
|
|
+ _doc = Document.fromJson(jsonDecode(
|
|
|
+ '[{"attributes":{"placeholder":true},"insert":"${widget.placeholder}\\n"}]'));
|
|
|
}
|
|
|
|
|
|
Widget child = CompositedTransformTarget(
|
|
@@ -503,7 +553,8 @@ class _RawEditorState extends EditorState
|
|
|
);
|
|
|
|
|
|
if (widget.scrollable) {
|
|
|
- final baselinePadding = EdgeInsets.only(top: _styles!.paragraph!.verticalSpacing.item1);
|
|
|
+ final baselinePadding =
|
|
|
+ EdgeInsets.only(top: _styles!.paragraph!.verticalSpacing.item1);
|
|
|
child = BaselineProxy(
|
|
|
textStyle: _styles!.paragraph!.style,
|
|
|
padding: baselinePadding,
|
|
@@ -534,7 +585,8 @@ class _RawEditorState extends EditorState
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- void _handleSelectionChanged(TextSelection selection, SelectionChangedCause cause) {
|
|
|
+ void _handleSelectionChanged(
|
|
|
+ TextSelection selection, SelectionChangedCause cause) {
|
|
|
widget.controller.updateSelection(selection, ChangeSource.LOCAL);
|
|
|
|
|
|
_selectionOverlay?.handlesVisible = _shouldShowSelectionHandles();
|
|
@@ -563,7 +615,9 @@ class _RawEditorState extends EditorState
|
|
|
_styles,
|
|
|
widget.enableInteractiveSelection,
|
|
|
_hasFocus,
|
|
|
- attrs.containsKey(Attribute.codeBlock.key) ? const EdgeInsets.all(16) : null,
|
|
|
+ attrs.containsKey(Attribute.codeBlock.key)
|
|
|
+ ? const EdgeInsets.all(16)
|
|
|
+ : null,
|
|
|
widget.embedBuilder,
|
|
|
_cursorController,
|
|
|
indentLevelCounts);
|
|
@@ -575,7 +629,8 @@ class _RawEditorState extends EditorState
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- EditableTextLine _getEditableTextLineFromNode(Line node, BuildContext context) {
|
|
|
+ EditableTextLine _getEditableTextLineFromNode(
|
|
|
+ Line node, BuildContext context) {
|
|
|
final textLine = TextLine(
|
|
|
line: node,
|
|
|
textDirection: _textDirection,
|
|
@@ -598,7 +653,8 @@ class _RawEditorState extends EditorState
|
|
|
return editableTextLine;
|
|
|
}
|
|
|
|
|
|
- Tuple2<double, double> _getVerticalSpacingForLine(Line line, DefaultStyles? defaultStyles) {
|
|
|
+ Tuple2<double, double> _getVerticalSpacingForLine(
|
|
|
+ Line line, DefaultStyles? defaultStyles) {
|
|
|
final attrs = line.style.attributes;
|
|
|
if (attrs.containsKey(Attribute.header.key)) {
|
|
|
final int? level = attrs[Attribute.header.key]!.value;
|
|
@@ -623,7 +679,8 @@ class _RawEditorState extends EditorState
|
|
|
return defaultStyles!.paragraph!.verticalSpacing;
|
|
|
}
|
|
|
|
|
|
- Tuple2<double, double> _getVerticalSpacingForBlock(Block node, DefaultStyles? defaultStyles) {
|
|
|
+ Tuple2<double, double> _getVerticalSpacingForBlock(
|
|
|
+ Block node, DefaultStyles? defaultStyles) {
|
|
|
final attrs = node.style.attributes;
|
|
|
if (attrs.containsKey(Attribute.quoteBlock.key)) {
|
|
|
return defaultStyles!.quote!.verticalSpacing;
|
|
@@ -666,7 +723,8 @@ class _RawEditorState extends EditorState
|
|
|
} else {
|
|
|
_keyboardVisibilityController = KeyboardVisibilityController();
|
|
|
_keyboardVisible = _keyboardVisibilityController!.isVisible;
|
|
|
- _keyboardVisibilitySubscription = _keyboardVisibilityController?.onChange.listen((visible) {
|
|
|
+ _keyboardVisibilitySubscription =
|
|
|
+ _keyboardVisibilityController?.onChange.listen((visible) {
|
|
|
_keyboardVisible = visible;
|
|
|
if (visible) {
|
|
|
_onChangeTextEditingValue();
|
|
@@ -689,7 +747,9 @@ class _RawEditorState extends EditorState
|
|
|
super.didChangeDependencies();
|
|
|
final parentStyles = EditorStyles.getStyles(context, true);
|
|
|
final defaultStyles = DefaultStyles.getInstance(context);
|
|
|
- _styles = (parentStyles != null) ? defaultStyles.merge(parentStyles) : defaultStyles;
|
|
|
+ _styles = (parentStyles != null)
|
|
|
+ ? defaultStyles.merge(parentStyles)
|
|
|
+ : defaultStyles;
|
|
|
|
|
|
if (widget.customStyles != null) {
|
|
|
_styles = _styles!.merge(widget.customStyles!);
|
|
@@ -749,7 +809,8 @@ class _RawEditorState extends EditorState
|
|
|
}
|
|
|
|
|
|
bool _shouldShowSelectionHandles() {
|
|
|
- return widget.showSelectionHandles && !widget.controller.selection.isCollapsed;
|
|
|
+ return widget.showSelectionHandles &&
|
|
|
+ !widget.controller.selection.isCollapsed;
|
|
|
}
|
|
|
|
|
|
void handleDelete(bool forward) {
|
|
@@ -760,7 +821,8 @@ class _RawEditorState extends EditorState
|
|
|
var textAfter = selection.textAfter(plainText);
|
|
|
if (selection.isCollapsed) {
|
|
|
if (!forward && textBefore.isNotEmpty) {
|
|
|
- final characterBoundary = _previousCharacter(textBefore.length, textBefore, true);
|
|
|
+ final characterBoundary =
|
|
|
+ _previousCharacter(textBefore.length, textBefore, true);
|
|
|
textBefore = textBefore.substring(0, characterBoundary);
|
|
|
cursorPosition = characterBoundary;
|
|
|
}
|
|
@@ -784,15 +846,13 @@ class _RawEditorState extends EditorState
|
|
|
final selection = widget.controller.selection;
|
|
|
final plainText = textEditingValue.text;
|
|
|
if (shortcut == InputShortcut.SAVE) {
|
|
|
- bool saved = await widget.controller.save();
|
|
|
- if (!saved) {
|
|
|
- log('Unabled to save document.');
|
|
|
- }
|
|
|
+ widget.controller.save();
|
|
|
return;
|
|
|
}
|
|
|
if (shortcut == InputShortcut.COPY) {
|
|
|
if (!selection.isCollapsed) {
|
|
|
- await Clipboard.setData(ClipboardData(text: selection.textInside(plainText)));
|
|
|
+ await Clipboard.setData(
|
|
|
+ ClipboardData(text: selection.textInside(plainText)));
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
@@ -809,7 +869,8 @@ class _RawEditorState extends EditorState
|
|
|
);
|
|
|
|
|
|
textEditingValue = TextEditingValue(
|
|
|
- text: selection.textBefore(plainText) + selection.textAfter(plainText),
|
|
|
+ text:
|
|
|
+ selection.textBefore(plainText) + selection.textAfter(plainText),
|
|
|
selection: TextSelection.collapsed(offset: selection.start),
|
|
|
);
|
|
|
}
|
|
@@ -827,7 +888,8 @@ class _RawEditorState extends EditorState
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- if (shortcut == InputShortcut.SELECT_ALL && widget.enableInteractiveSelection) {
|
|
|
+ if (shortcut == InputShortcut.SELECT_ALL &&
|
|
|
+ widget.enableInteractiveSelection) {
|
|
|
widget.controller.updateSelection(
|
|
|
selection.copyWith(
|
|
|
baseOffset: 0,
|
|
@@ -881,14 +943,16 @@ class _RawEditorState extends EditorState
|
|
|
void _onChangeTextEditingValue() {
|
|
|
_showCaretOnScreen();
|
|
|
updateRemoteValueIfNeeded();
|
|
|
- _cursorController.startOrStopCursorTimerIfNeeded(_hasFocus, widget.controller.selection);
|
|
|
+ _cursorController.startOrStopCursorTimerIfNeeded(
|
|
|
+ _hasFocus, widget.controller.selection);
|
|
|
if (hasConnection) {
|
|
|
_cursorController
|
|
|
..stopCursorTimer(resetCharTicks: false)
|
|
|
..startCursorTimer();
|
|
|
}
|
|
|
|
|
|
- SchedulerBinding.instance!.addPostFrameCallback((_) => _updateOrDisposeSelectionOverlayIfNeeded());
|
|
|
+ SchedulerBinding.instance!.addPostFrameCallback(
|
|
|
+ (_) => _updateOrDisposeSelectionOverlayIfNeeded());
|
|
|
if (mounted) {
|
|
|
setState(() {
|
|
|
// Use widget.controller.value in build()
|
|
@@ -931,7 +995,8 @@ class _RawEditorState extends EditorState
|
|
|
|
|
|
void _handleFocusChanged() {
|
|
|
openOrCloseConnection();
|
|
|
- _cursorController.startOrStopCursorTimerIfNeeded(_hasFocus, widget.controller.selection);
|
|
|
+ _cursorController.startOrStopCursorTimerIfNeeded(
|
|
|
+ _hasFocus, widget.controller.selection);
|
|
|
_updateOrDisposeSelectionOverlayIfNeeded();
|
|
|
if (_hasFocus) {
|
|
|
WidgetsBinding.instance!.addObserver(this);
|
|
@@ -962,7 +1027,8 @@ class _RawEditorState extends EditorState
|
|
|
_showCaretOnScreenScheduled = false;
|
|
|
|
|
|
final viewport = RenderAbstractViewport.of(getRenderEditor())!;
|
|
|
- final editorOffset = getRenderEditor()!.localToGlobal(const Offset(0, 0), ancestor: viewport);
|
|
|
+ final editorOffset = getRenderEditor()!
|
|
|
+ .localToGlobal(const Offset(0, 0), ancestor: viewport);
|
|
|
final offsetInViewport = _scrollController!.offset + editorOffset.dy;
|
|
|
|
|
|
final offset = getRenderEditor()!.getOffsetToRevealCursor(
|
|
@@ -1045,7 +1111,8 @@ class _RawEditorState extends EditorState
|
|
|
final value = textEditingValue;
|
|
|
final data = await Clipboard.getData(Clipboard.kTextPlain);
|
|
|
if (data != null) {
|
|
|
- final length = textEditingValue.selection.end - textEditingValue.selection.start;
|
|
|
+ final length =
|
|
|
+ textEditingValue.selection.end - textEditingValue.selection.start;
|
|
|
widget.controller.replaceText(
|
|
|
value.selection.start,
|
|
|
length,
|
|
@@ -1054,7 +1121,9 @@ class _RawEditorState extends EditorState
|
|
|
);
|
|
|
// move cursor to the end of pasted text selection
|
|
|
widget.controller.updateSelection(
|
|
|
- TextSelection.collapsed(offset: value.selection.start + data.text!.length), ChangeSource.LOCAL);
|
|
|
+ TextSelection.collapsed(
|
|
|
+ offset: value.selection.start + data.text!.length),
|
|
|
+ ChangeSource.LOCAL);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1064,7 +1133,8 @@ class _RawEditorState extends EditorState
|
|
|
if (data == null) {
|
|
|
return false;
|
|
|
}
|
|
|
- return textEditingValue.text.length - value.text.length == data.text!.length;
|
|
|
+ return textEditingValue.text.length - value.text.length ==
|
|
|
+ data.text!.length;
|
|
|
}
|
|
|
|
|
|
@override
|
|
@@ -1097,7 +1167,8 @@ class _RawEditorState extends EditorState
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
- void userUpdateTextEditingValue(TextEditingValue value, SelectionChangedCause cause) {
|
|
|
+ void userUpdateTextEditingValue(
|
|
|
+ TextEditingValue value, SelectionChangedCause cause) {
|
|
|
// TODO: implement userUpdateTextEditingValue
|
|
|
}
|
|
|
}
|
|
@@ -1147,7 +1218,8 @@ class _Editor extends MultiChildRenderObjectWidget {
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
- void updateRenderObject(BuildContext context, covariant RenderEditor renderObject) {
|
|
|
+ void updateRenderObject(
|
|
|
+ BuildContext context, covariant RenderEditor renderObject) {
|
|
|
renderObject
|
|
|
..document = document
|
|
|
..container = document.root
|