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

[FR] add actions to increase/decrease indentation #904

Open TatsuUkraine opened 1 month ago

TatsuUkraine commented 1 month ago

Description

Ability to update indentation

Impact

Update text indentation, create nested lists

Additional Context

No response

LucasXu0 commented 1 month ago

Using tab to indent should work.

If you want to extend more blocks to support indent, you can add the types into this array.

final indentableBlockTypes = {
  BulletedListBlockKeys.type,
  NumberedListBlockKeys.type,
  TodoListBlockKeys.type,
  ParagraphBlockKeys.type,
};
TatsuUkraine commented 1 month ago

I was searching for an easy way to programmatically increase/decrease indentation for a selection in the mobile app, using custom toolbar actions

TatsuUkraine commented 1 month ago

I build own logic to update delta in the editor on button click since I didn't find sort of like a command, where you can pass selection, so it could update list items indentation for me, similar to toggleAttribute or formatNode

LucasXu0 commented 1 month ago

You can execute the command directly, but it relies on the selection. You must set a selection before executing this command.

indentCommand.execute(editorState);