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

[CKEditor5] MathType plugin throws error when editor.sourceElement is not defined #829

Open
DawidKossowski opened this issue Jun 30, 2023 · 1 comment
Labels
type:bug Something isn't working

Comments

@DawidKossowski
Copy link

DawidKossowski commented Jun 30, 2023

Description

When using an editor that doesn't have the sourceElement property, the MathType plugin throws an error during the destroy process.

We utilize various versions of editors, such as the headless editor in our internal features or the Multi-root editor, which do not include the sourceElement property. This results in error since the thecurrentInstance variable in the theMathType plugin is not defined (the plugin attempts to destroy currentInstance, which is undefined).

Reference: https://github.com/wiris/html-integrations/blob/stable/packages/ckeditor5/src/plugin.js#L68C5-L68C20

It could be simply fixed by adding the if statement:

destroy() { // eslint-disable-line class-methods-use-this
    if( currentInstance ) {
        currentInstance.destroy();
    }
 }

Environment

Which version of MathType does this happen in?

Latest

What is the relevant software and their versions?

CKEditor5

Steps to reproduce

  1. Create multi-root editor.
  2. Add MathType to the editor plugins.
  3. Call editor.destroy().

Expected result

The editor should be destroyed without errors.

Actual result

The error is thrown.
TypeError: Cannot read properties of undefined (reading 'removeEvents') at MathType.destroy

@DawidKossowski DawidKossowski added the type:bug Something isn't working label Jun 30, 2023
@Mgsy
Copy link

Mgsy commented Jul 10, 2023

The same issue can be reproduced with the TrackChangesData plugin and calling one of its methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants