Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MioVisman opened this issue Apr 9, 2023 · 2 comments
Labels
Milestone

Comments

@MioVisman
Copy link

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 added a commit to forkbb/forkbb that referenced this issue Apr 9, 2023
@samclarke samclarke added the Bug label Apr 10, 2023
@samclarke samclarke added this to the v3.3.0 milestone Apr 10, 2023
@samclarke
Copy link
Owner

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

@MioVisman
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants