AppFlowy-IO / appflowy-editor

A highly customizable rich-text editor for Flutter. The AppFlowy Editor project for AppFlowy and beyond.
https://pub.dev/packages/appflowy_editor
Other
473 stars 201 forks source link

fix: ignore backspace on empty table cells to avoid editor crash #964

Open saif-ellafi opened 1 week ago

saif-ellafi commented 1 week ago

Pressing "delete" (aka Backspace) on Android crashes the editor when called inside the empty cell of a table. It leaves the table in an invalid state, crashing the Editor.

This fix or workaround ignores backspaces called inside table cells at the first offset position of the cursor.

Any suggestions welcome!

rileyhawk1417 commented 21 hours ago

Hi @saif-ellafi seems like the fix works. Although table editing is not supported on mobile yet. The fix does help for some people who would manually want to bring the table editing experience to mobile.

I had tested before the fix and after.

Before (this was done on the release version of AppFlowy 0.7.3(2907301))

https://github.com/user-attachments/assets/1cc93b9e-d846-4f99-88b3-483d478b992e

After (this was done on AppFlowy-Editor with the example file for desktop)

https://github.com/user-attachments/assets/e5c99982-65d2-40d3-813b-2f232e23b638

@LucasXu0 do you mind confirming if this fix has already been implemented yet? Not sure how far along mobile support for table editing is.

rileyhawk1417 commented 21 hours ago

I did run the tests locally on Arch Linux no errors happened although not sure why the CI test failed.

saif-ellafi commented 20 hours ago

Hello @rileyhawk1417 - thanks so much for checking out.

Yes with my fixes (also the other PRs are very important), I made it to production for my app and users are fine with it. I have added table controls in the toolbar to add and remove rows and columns and pretty much successful. It doesn't work with the in-place controls like desktop but honestly I find it even better this way through toolbar controls.

Best regards

LucasXu0 commented 8 hours ago

@saif-ellafi I can confirm that it will fix the table issue. Can you format your code to pass the CI?

saif-ellafi commented 41 minutes ago

Hi @LucasXu0 - will take a look but the errors say absolutely nothing, apparently failing in the Ubuntu tests, could it be a random error? will run tests locally on my Ubuntu and see.

...
Downloading packages...
Got dependencies in `./example`.
Analyzing appflowy-editor...                                    
No issues found! (ran in 23.2s)
Formatted lib/src/editor/editor_component/service/ime/delta_input_on_delete_impl.dart
Formatted 592 files (1 changed) in 1.74 seconds.
Error: Process completed with exit code 1.