fix: editor will crash if deleting all nodes (#1037)
* fix: editor will crash if deleting all nodes * chore: disable windows ci
This commit is contained in:
parent
8868c50aef
commit
1df3cb1a1f
1 changed files with 41 additions and 9 deletions
|
|
@ -105,9 +105,7 @@ class _DesktopEditorState extends State<DesktopEditor> {
|
|||
height: 150,
|
||||
),
|
||||
),
|
||||
footer: const SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
footer: _buildFooter(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
@ -216,6 +214,32 @@ class _DesktopEditorState extends State<DesktopEditor> {
|
|||
];
|
||||
}
|
||||
|
||||
Widget _buildFooter() {
|
||||
return SizedBox(
|
||||
height: 100,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () async {
|
||||
// check if the document is empty, if so, add a new paragraph block.
|
||||
if (editorState.document.root.children.isEmpty) {
|
||||
final transaction = editorState.transaction;
|
||||
transaction.insertNode(
|
||||
[0],
|
||||
paragraphNode(),
|
||||
);
|
||||
await editorState.apply(transaction);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
editorState.selection = Selection.collapsed(
|
||||
Position(path: [0]),
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String? _buildAutoCompleteTextProvider(
|
||||
BuildContext context,
|
||||
Node node,
|
||||
|
|
|
|||
Loading…
Reference in a new issue