diff --git a/lib/src/widgets/raw_editor.dart b/lib/src/widgets/raw_editor.dart index b8218f8b..4cbf4193 100644 --- a/lib/src/widgets/raw_editor.dart +++ b/lib/src/widgets/raw_editor.dart @@ -675,17 +675,16 @@ class RawEditorState extends EditorState if (event is! RawKeyDownEvent) { return KeyEventResult.ignored; } + // Handle indenting blocks when pressing the tab key. + if (event.logicalKey == LogicalKeyboardKey.tab) { + return _handleTabKey(event); + } // Don't handle key if there is an active selection. if (controller.selection.baseOffset != controller.selection.extentOffset) { return KeyEventResult.ignored; } - // Handle indenting blocks when pressing the tab key. - if (event.logicalKey == LogicalKeyboardKey.tab) { - return _handleTabKey(event); - } - // Handle inserting lists when space is pressed following // a list initiating phrase. if (event.logicalKey == LogicalKeyboardKey.space) { @@ -736,6 +735,19 @@ class RawEditorState extends EditorState return KeyEventResult.handled; } + if (controller.selection.baseOffset != controller.selection.extentOffset) { + if (child.node == null || child.node!.parent == null) { + return KeyEventResult.handled; + } + final parentBlock = child.node!.parent!; + if (parentBlock.style.containsKey(Attribute.ol.key) || + parentBlock.style.containsKey(Attribute.ul.key) || + parentBlock.style.containsKey(Attribute.checked.key)) { + controller.indentSelection(!event.isShiftPressed); + } + return KeyEventResult.handled; + } + if (child.node == null) { return insertTabCharacter(); }