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:
Lucas 2025-02-18 16:22:05 +08:00 • committed by GitHub
commit 1df3cb1a1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,