taiga-family / editor

Text editor
https://taiga-family.github.io/editor/
Apache License 2.0
26 stars 7 forks source link

🐞 - hotkeys of disabled tools keep on working #1523

Open Gleb1nho opened 1 week ago

Gleb1nho commented 1 week ago

Reproduction url

https://stackblitz.com/edit/angular-yiw4rr?file=src%2Fapp%2Fapp.component.ts

Description

Hotkeys of disabled tools keep on working.

Steps to reproduce:

  1. Create editor
  2. Add only undo/redo tool (or no tools at all)
  3. Type some text into the editor
  4. Select the text
  5. Press cmd + b/ctrl + b

Result: text gets bolder Expected result: text does not change

Also works with other hotkeys: cmd + u, cmd + opt + 1/2/3, etc.

Taiga UI version

4.9.0

Browser Used

Chrome

OS Used

macOS

hakimio commented 2 days ago

If you don't want some extensions, you can just provide your own set of editor extensions instead of the default ones: https://github.com/taiga-family/editor/blob/fcf629b839d1d6b682cbfef12863c61c6a4a2a0a/projects/demo/src/app/pages/font/examples/2/index.ts#L26

import type {Extension, Mark, Node} from '@tiptap/core';

export const TUI_EDITOR_DEFAULT_EXTENSIONS: readonly (Extension | Mark | Node | Promise<Extension | Mark | Node>)[] = [
    import('@tiptap/extension-blockquote').then(({default: blockquote}) => blockquote),
    import('@tiptap/extension-bold').then(({default: bold}) => bold),
    import('@tiptap/extension-bullet-list').then(({default: bulletList}) => bulletList),
    import('@tiptap/extension-document').then(({default: document}) => document),
    import('@tiptap/extension-hard-break').then(({default: hardBreak}) => hardBreak),
    import('@tiptap/extension-history').then(({default: history}) => history.configure({
        depth: 100,
        newGroupDelay: 500
    })),
    import('@taiga-ui/editor/extensions/horizontal').then(({TuiHorizontalRule: horizontalRule}) => horizontalRule),
    import('@tiptap/extension-italic').then(({default: italic}) => italic),
    import('@tiptap/extension-list-item').then(({default: listItem}) => listItem),
    import('@tiptap/extension-task-list').then(({default: taskList}) => taskList),
    import('@tiptap/extension-task-item').then(({default: taskItem}) => taskItem.configure({
        nested: true
    })),
    import('@tiptap/extension-ordered-list').then(({default: orderedList}) => orderedList),
    import('@tiptap/extension-paragraph').then(({default: paragraph}) => paragraph),
    import('@tiptap/extension-strike').then(({default: strike}) => strike),
    import('@tiptap/extension-text').then(({default: text}) => text),
    import('@tiptap/extension-text-style').then(({default: textStyle}) => textStyle),
    import('@tiptap/extension-underline').then(({default: underline}) => underline),
    import('@taiga-ui/editor/extensions/link').then(({TuiLink: link}) => link.configure({
        HTMLAttributes: {
            target: '_blank',
            rel: 'noopener noreferrer nofollow'
        }
    }))
];
waterplea commented 2 days ago

I think this issue is about adding this info to the docs, as people might think when you do not have a button in toolbar — hotkeys would also stop working, but these are actually two separate things.