springload / draftail

📝🍸 A configurable rich text editor built with Draft.js
https://www.draftail.org/
MIT License
613 stars 64 forks source link

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

Open thibaudcolas opened 6 years ago

thibaudcolas commented 6 years ago

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:


Initially reported at https://github.com/springload/wagtaildraftail/issues/49 by @tomdyson.

thibaudcolas commented 5 years ago

I think this needs to be done with the controls API / prop (https://www.draftail.org/docs/arbitrary-controls), using ToolbarButton to add a button to the toolbar.

Then, the fun bit of the task is to figure out how to dedent/indent content when the user clicks the button.

mpkasp commented 4 years ago

Draftail's docs mentions using the tab key to indent a paragraph "if enabled". This does not seem to work for me on my mac. I tried in the examples on Draftail's site, my wagtail site, on 2 different macs and on Safari and Chrome.

Are you referring to indenting a paragraph? e.g. what happens when you press "tab" in front of text in a word document, right?

thibaudcolas commented 3 years ago

If you’re referring to https://www.draftail.org/docs/keyboard-shortcuts, it says "Increase list indentation". This is only for list items, where the indentation in the editor denotes the list nesting in HTML.