SCEditor icon indicating copy to clipboard operation
SCEditor copied to clipboard

sceditor.formats.bbcode.remove() -> Uncaught TypeError: bbcodeHandlers[bbcode] is undefined

Open MioVisman opened this issue 1 year ago • 2 comments

Firefox 108 SCEditor 3.2.0 format: bbcode

        sceditor.create(textarea, options);
        instance = sceditor.instance(textarea);

        var forDelete = ['youtube', 'rtl', 'ltr'];

        if (!linkEnabled) {
            forDelete = forDelete.concat('url', 'img', 'email');
        }

        for (var bbcodeForDelete of forDelete) {
            sceditor.command.remove(bbcodeForDelete);
            sceditor.formats.bbcode.remove(bbcodeForDelete);
        }

If there is "rtl" in the list for deletion, then this error occurs anyway. If there is 'img', then when using emoticons.

The moment the error occurred:

  1. Apparently when sending a message, because the server reports that an empty message has arrived.
  2. And when switching from visual mode to code and back.

i3

MioVisman avatar Apr 09 '23 12:04 MioVisman

Thanks for reporting!

BBCodes need to be removed before the editor is created (they can somewhat be modified after creation for backwards compatibility but not removed). It shouldn't be throwing an error though so that is a bug.

The current behaviour really isn't great. The proposal for v4 would solve this by requiring commands/BBCodes to be explicitly passed in the constructor so it's obvious where they come from and would prevent these issues.

For now, removing them before creation should work. Something like this: https://jsbin.com/bocemolotu/edit?html,js,output

samclarke avatar Apr 10 '23 16:04 samclarke

Thank you! I checked, there are no errors at the moment.

MioVisman avatar Apr 10 '23 16:04 MioVisman