Skip to content

Add example of a shortcut button for indentation / unindentation #111

@thibaudcolas

Description

@thibaudcolas

Only available as a keyboard shortcut at the moment. Applies to blocks that have a notion of depth – list items only at the moment.

This could be built as an example / extension, using the controls API, instead of something that’s built-in. It would be nice to have this as a demo directly in the repo though.

Here is how it would work roughly:

  • Add button(s) in the toolbar using the controls API.
  • On click, retrieve the editor state with the getEditorState prop of the control
  • Check where the selection is (editorState.getSelection())
  • If it's in a block that's a list item, apply the right effect (indent / dedent) by incrementing/decrementing the block’s depth.

Initially reported at springload/wagtaildraftail#49 by @tomdyson.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions