awcodes / scribble

MIT License
43 stars 6 forks source link

[Bug]: Heading buttons are not working #26

Closed monteduro closed 3 months ago

monteduro commented 3 months ago

What happened?

It seems that the heading buttons are not working. The keyboard shortcut (cmd alt 2) is fine, but if I select the text and click the button, nothing happens.

How to reproduce the bug

Screenshot 2024-04-08 alle 16 53 55

Package Version

0.3.6-alpha

PHP Version

8.2.15

Laravel Version

10.48.4

Which operating systems does with happen with?

macOS

Notes

No response

monteduro commented 3 months ago

the bug seems to be here: vendor/awcodes/scribble/resources/js/utils.js

export const commandRunner = (editor, commands, args = []) => {
    commands.forEach(command => {
        editor.chain().focus()[command.command](command?.arguments.length > 0 ? command.arguments : args).run()
    })
}

command?.arguments is a proxy object then the check on length, if it is and object, always fail.

I checked in the minified version:

Bi = (n, e, t = []) => {
    e.forEach((r) => {
        n.chain().focus()[r.command](r?.arguments.length > 0 ? r.arguments : t).run();
    });
};

I'm not a frontender, but i hope it helps