Skip to content

Commit

Permalink
chore: tab extension fix #2 (#1493)
Browse files Browse the repository at this point in the history
Co-authored-by: taiga-family-bot <[email protected]>
  • Loading branch information
hakimio and taiga-family-bot authored Oct 2, 2024
1 parent d4f65ab commit 3d504a1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions projects/editor/extensions/indent-outdent/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import type {Editor, KeyboardShortcutCommand} from '@tiptap/core';
import {Extension} from '@tiptap/core';

export function tuiIsOrderedOrBulletList(editor: Editor): boolean {
return editor.isActive('bulletList') || editor.isActive('orderedList');
export function tuiIsListActive(editor: Editor): boolean {
return (
editor.isActive('bulletList') ||
editor.isActive('orderedList') ||
editor.isActive('taskList')
);
}

export const TuiTabExtension = Extension.create({
name: 'indent',
priority: 50,

addKeyboardShortcuts(): Record<string, KeyboardShortcutCommand> {
return {
Tab: () =>
tuiIsOrderedOrBulletList(this.editor)
tuiIsListActive(this.editor)
? false
: this.editor.commands.insertContent('\t'),
};
Expand Down

0 comments on commit 3d504a1

Please sign in to comment.