angular-editor icon indicating copy to clipboard operation
angular-editor copied to clipboard

Tab keypress does not indent content or bulleted lists

Open caitlinrouille opened this issue 3 years ago • 1 comments

Can we have the capability to add indentation when you press the tab on the keyboard for paragraphs and bullets?

caitlinrouille avatar Feb 21 '23 16:02 caitlinrouille

Good news! Tab key functionality can be added using custom event handling.

Solution:

@ViewChild('editor') editor: AngularEditorComponent;

ngAfterViewInit() {
  const textarea = this.editor.textArea.nativeElement;
  
  textarea.addEventListener('keydown', (e: KeyboardEvent) => {
    if (e.key === 'Tab') {
      e.preventDefault();
      if (e.shiftKey) {
        document.execCommand('outdent');
      } else {
        document.execCommand('indent');
      }
    }
  });
}

This enables:

  • Tab → indent
  • Shift+Tab → outdent

Works for both paragraphs and lists!

Note: Built-in Tab support is planned for v3.2+ with keyboard shortcuts feature (#552).

If you have additional questions, feel free to open a new issue!

kolkov avatar Nov 22 '25 01:11 kolkov