Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
75453e6a
Unverified
Commit
75453e6a
authored
Apr 02, 2021
by
Ricardo Canastro
Committed by
GitHub
Apr 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support block delete with word and line modifiers (#77172)
parent
2369d76a
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1827 additions
and
141 deletions
+1827
-141
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+374
-54
default_text_editing_actions.dart
...flutter/lib/src/widgets/default_text_editing_actions.dart
+48
-0
default_text_editing_shortcuts.dart
...utter/lib/src/widgets/default_text_editing_shortcuts.dart
+56
-0
text_editing_intents.dart
packages/flutter/lib/src/widgets/text_editing_intents.dart
+48
-0
editable_test.dart
packages/flutter/test/rendering/editable_test.dart
+1301
-87
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
75453e6a
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/widgets/default_text_editing_actions.dart
View file @
75453e6a
...
...
@@ -36,6 +36,12 @@ class DefaultTextEditingActions extends Actions{
// are called on which platform.
static
final
Map
<
Type
,
Action
<
Intent
>>
_shortcutsActions
=
<
Type
,
Action
<
Intent
>>{
DoNothingAndStopPropagationTextIntent:
_DoNothingAndStopPropagationTextAction
(),
DeleteTextIntent:
_DeleteTextAction
(),
DeleteByWordTextIntent:
_DeleteByWordTextAction
(),
DeleteByLineTextIntent:
_DeleteByLineTextAction
(),
DeleteForwardTextIntent:
_DeleteForwardTextAction
(),
DeleteForwardByWordTextIntent:
_DeleteForwardByWordTextAction
(),
DeleteForwardByLineTextIntent:
_DeleteForwardByLineTextAction
(),
ExtendSelectionDownTextIntent:
_ExtendSelectionDownTextAction
(),
ExtendSelectionLeftByLineTextIntent:
_ExtendSelectionLeftByLineTextAction
(),
ExtendSelectionLeftByWordTextIntent:
_ExtendSelectionLeftByWordTextAction
(),
...
...
@@ -76,6 +82,48 @@ class _DoNothingAndStopPropagationTextAction extends TextEditingAction<DoNothing
void
invoke
(
DoNothingAndStopPropagationTextIntent
intent
,
[
BuildContext
?
context
])
{}
}
class
_DeleteTextAction
extends
TextEditingAction
<
DeleteTextIntent
>
{
@override
Object
?
invoke
(
DeleteTextIntent
intent
,
[
BuildContext
?
context
])
{
textEditingActionTarget
!.
renderEditable
.
delete
(
SelectionChangedCause
.
keyboard
);
}
}
class
_DeleteByWordTextAction
extends
TextEditingAction
<
DeleteByWordTextIntent
>
{
@override
Object
?
invoke
(
DeleteByWordTextIntent
intent
,
[
BuildContext
?
context
])
{
textEditingActionTarget
!.
renderEditable
.
deleteByWord
(
SelectionChangedCause
.
keyboard
,
false
);
}
}
class
_DeleteByLineTextAction
extends
TextEditingAction
<
DeleteByLineTextIntent
>
{
@override
Object
?
invoke
(
DeleteByLineTextIntent
intent
,
[
BuildContext
?
context
])
{
textEditingActionTarget
!.
renderEditable
.
deleteByLine
(
SelectionChangedCause
.
keyboard
);
}
}
class
_DeleteForwardTextAction
extends
TextEditingAction
<
DeleteForwardTextIntent
>
{
@override
Object
?
invoke
(
DeleteForwardTextIntent
intent
,
[
BuildContext
?
context
])
{
textEditingActionTarget
!.
renderEditable
.
deleteForward
(
SelectionChangedCause
.
keyboard
);
}
}
class
_DeleteForwardByWordTextAction
extends
TextEditingAction
<
DeleteForwardByWordTextIntent
>
{
@override
Object
?
invoke
(
DeleteForwardByWordTextIntent
intent
,
[
BuildContext
?
context
])
{
textEditingActionTarget
!.
renderEditable
.
deleteForwardByWord
(
SelectionChangedCause
.
keyboard
,
false
);
}
}
class
_DeleteForwardByLineTextAction
extends
TextEditingAction
<
DeleteForwardByLineTextIntent
>
{
@override
Object
?
invoke
(
DeleteForwardByLineTextIntent
intent
,
[
BuildContext
?
context
])
{
textEditingActionTarget
!.
renderEditable
.
deleteForwardByLine
(
SelectionChangedCause
.
keyboard
);
}
}
class
_ExpandSelectionLeftByLineTextAction
extends
TextEditingAction
<
ExpandSelectionLeftByLineTextIntent
>
{
@override
Object
?
invoke
(
ExpandSelectionLeftByLineTextIntent
intent
,
[
BuildContext
?
context
])
{
...
...
packages/flutter/lib/src/widgets/default_text_editing_shortcuts.dart
View file @
75453e6a
...
...
@@ -161,6 +161,12 @@ class DefaultTextEditingShortcuts extends Shortcuts {
);
static
final
Map
<
LogicalKeySet
,
Intent
>
_androidShortcuts
=
<
LogicalKeySet
,
Intent
>{
LogicalKeySet
(
LogicalKeyboardKey
.
backspace
):
const
DeleteTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
control
,
LogicalKeyboardKey
.
backspace
):
const
DeleteByWordTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
backspace
):
const
DeleteByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
delete
):
const
DeleteForwardTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
control
,
LogicalKeyboardKey
.
delete
):
const
DeleteForwardByWordTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
delete
):
const
DeleteForwardByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowDown
):
const
MoveSelectionToEndTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowLeft
):
const
MoveSelectionLeftByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowRight
):
const
MoveSelectionRightByLineTextIntent
(),
...
...
@@ -195,9 +201,17 @@ class DefaultTextEditingShortcuts extends Shortcuts {
// * Meta + shift + arrow up
// * Shift + end
// * Shift + home
// * Meta + delete
// * Meta + backspace
};
static
final
Map
<
LogicalKeySet
,
Intent
>
_fuchsiaShortcuts
=
<
LogicalKeySet
,
Intent
>{
LogicalKeySet
(
LogicalKeyboardKey
.
backspace
):
const
DeleteTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
control
,
LogicalKeyboardKey
.
backspace
):
const
DeleteByWordTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
backspace
):
const
DeleteByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
delete
):
const
DeleteForwardTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
control
,
LogicalKeyboardKey
.
delete
):
const
DeleteForwardByWordTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
delete
):
const
DeleteForwardByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowDown
):
const
MoveSelectionToEndTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowLeft
):
const
MoveSelectionLeftByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowRight
):
const
MoveSelectionRightByLineTextIntent
(),
...
...
@@ -232,9 +246,17 @@ class DefaultTextEditingShortcuts extends Shortcuts {
// * Meta + shift + arrow up
// * Shift + end
// * Shift + home
// * Meta + delete
// * Meta + backspace
};
static
final
Map
<
LogicalKeySet
,
Intent
>
_iOSShortcuts
=
<
LogicalKeySet
,
Intent
>{
LogicalKeySet
(
LogicalKeyboardKey
.
backspace
):
const
DeleteTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
control
,
LogicalKeyboardKey
.
backspace
):
const
DeleteByWordTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
backspace
):
const
DeleteByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
delete
):
const
DeleteForwardTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
control
,
LogicalKeyboardKey
.
delete
):
const
DeleteForwardByWordTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
delete
):
const
DeleteForwardByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowDown
):
const
MoveSelectionToEndTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowLeft
):
const
MoveSelectionLeftByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowRight
):
const
MoveSelectionRightByLineTextIntent
(),
...
...
@@ -269,9 +291,17 @@ class DefaultTextEditingShortcuts extends Shortcuts {
// * Meta + shift + arrow up
// * Shift + end
// * Shift + home
// * Meta + delete
// * Meta + backspace
};
static
final
Map
<
LogicalKeySet
,
Intent
>
_linuxShortcuts
=
<
LogicalKeySet
,
Intent
>{
LogicalKeySet
(
LogicalKeyboardKey
.
backspace
):
const
DeleteTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
control
,
LogicalKeyboardKey
.
backspace
):
const
DeleteByWordTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
backspace
):
const
DeleteByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
delete
):
const
DeleteForwardTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
control
,
LogicalKeyboardKey
.
delete
):
const
DeleteForwardByWordTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
delete
):
const
DeleteForwardByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowDown
):
const
MoveSelectionToEndTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowLeft
):
const
MoveSelectionLeftByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowRight
):
const
MoveSelectionRightByLineTextIntent
(),
...
...
@@ -306,9 +336,17 @@ class DefaultTextEditingShortcuts extends Shortcuts {
// * Meta + shift + arrow up
// * Shift + end
// * Shift + home
// * Meta + delete
// * Meta + backspace
};
static
final
Map
<
LogicalKeySet
,
Intent
>
_macShortcuts
=
<
LogicalKeySet
,
Intent
>{
LogicalKeySet
(
LogicalKeyboardKey
.
backspace
):
const
DeleteTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
backspace
):
const
DeleteByWordTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
meta
,
LogicalKeyboardKey
.
backspace
):
const
DeleteByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
delete
):
const
DeleteForwardTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
delete
):
const
DeleteForwardByWordTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
meta
,
LogicalKeyboardKey
.
delete
):
const
DeleteForwardByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowDown
):
const
MoveSelectionRightByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowLeft
):
const
MoveSelectionLeftByWordTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowRight
):
const
MoveSelectionRightByWordTextIntent
(),
...
...
@@ -343,9 +381,17 @@ class DefaultTextEditingShortcuts extends Shortcuts {
// * Home
// * Shift + end
// * Shift + home
// * Control + delete
// * Control + backspace
};
static
final
Map
<
LogicalKeySet
,
Intent
>
_windowsShortcuts
=
<
LogicalKeySet
,
Intent
>{
LogicalKeySet
(
LogicalKeyboardKey
.
backspace
):
const
DeleteTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
control
,
LogicalKeyboardKey
.
backspace
):
const
DeleteByWordTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
backspace
):
const
DeleteByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
delete
):
const
DeleteForwardTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
control
,
LogicalKeyboardKey
.
delete
):
const
DeleteForwardByWordTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
delete
):
const
DeleteForwardByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowDown
):
const
MoveSelectionToEndTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowLeft
):
const
MoveSelectionLeftByLineTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowRight
):
const
MoveSelectionRightByLineTextIntent
(),
...
...
@@ -380,11 +426,21 @@ class DefaultTextEditingShortcuts extends Shortcuts {
// * Meta + shift + arrow left
// * Meta + shift + arrow right
// * Meta + shift + arrow up
// * Meta + delete
// * Meta + backspace
};
// Web handles its text selection natively and doesn't use any of these
// shortcuts in Flutter.
static
final
Map
<
LogicalKeySet
,
Intent
>
_webShortcuts
=
<
LogicalKeySet
,
Intent
>{
LogicalKeySet
(
LogicalKeyboardKey
.
backspace
):
const
DoNothingAndStopPropagationTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
delete
):
const
DoNothingAndStopPropagationTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
backspace
):
const
DoNothingAndStopPropagationTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
delete
):
const
DoNothingAndStopPropagationTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
control
,
LogicalKeyboardKey
.
backspace
):
const
DoNothingAndStopPropagationTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
control
,
LogicalKeyboardKey
.
delete
):
const
DoNothingAndStopPropagationTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
meta
,
LogicalKeyboardKey
.
backspace
):
const
DoNothingAndStopPropagationTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
meta
,
LogicalKeyboardKey
.
delete
):
const
DoNothingAndStopPropagationTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowDown
):
const
DoNothingAndStopPropagationTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowLeft
):
const
DoNothingAndStopPropagationTextIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
alt
,
LogicalKeyboardKey
.
arrowRight
):
const
DoNothingAndStopPropagationTextIntent
(),
...
...
packages/flutter/lib/src/widgets/text_editing_intents.dart
View file @
75453e6a
...
...
@@ -4,6 +4,54 @@
import
'actions.dart'
;
/// An [Intent] to delete a character in the backwards direction.
///
/// {@macro flutter.widgets.TextEditingIntents.seeAlso}
class
DeleteTextIntent
extends
Intent
{
/// Creates an instance of DeleteTextIntent.
const
DeleteTextIntent
();
}
/// An [Intent] to delete a word in the backwards direction.
///
/// {@macro flutter.widgets.TextEditingIntents.seeAlso}
class
DeleteByWordTextIntent
extends
Intent
{
/// Creates an instance of DeleteByWordTextIntent.
const
DeleteByWordTextIntent
();
}
/// An [Intent] to delete a line in the backwards direction.
///
/// {@macro flutter.widgets.TextEditingIntents.seeAlso}
class
DeleteByLineTextIntent
extends
Intent
{
/// Creates an instance of DeleteByLineTextIntent.
const
DeleteByLineTextIntent
();
}
/// An [Intent] to delete in the forward direction.
///
/// {@macro flutter.widgets.TextEditingIntents.seeAlso}
class
DeleteForwardTextIntent
extends
Intent
{
/// Creates an instance of DeleteForwardTextIntent.
const
DeleteForwardTextIntent
();
}
/// An [Intent] to delete a word in the forward direction.
///
/// {@macro flutter.widgets.TextEditingIntents.seeAlso}
class
DeleteForwardByWordTextIntent
extends
Intent
{
/// Creates an instance of DeleteByWordTextIntent.
const
DeleteForwardByWordTextIntent
();
}
/// An [Intent] to delete a line in the forward direction.
///
/// {@macro flutter.widgets.TextEditingIntents.seeAlso}
class
DeleteForwardByLineTextIntent
extends
Intent
{
/// Creates an instance of DeleteByLineTextIntent.
const
DeleteForwardByLineTextIntent
();
}
/// An [Intent] to send the event straight to the engine, but only if a
/// TextEditingTarget is focused.
///
...
...
packages/flutter/test/rendering/editable_test.dart
View file @
75453e6a
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment