Skip to content

Align plugin throws "Cannot read properties of undefined (reading 'selectedCells')" when table plugin is not enabledΒ #573

@MKaranusic

Description

@MKaranusic

When using the Froala editor with selective plugin loading (pluginsEnabled), enabling only the "align" plugin causes a JavaScript error when attempting to apply text alignment (e.g., center, right, justify) to selected text.

Steps to Reproduce:

  1. Configure Froala editor with selective plugins:
  2. Add some text to the editor
  3. Select the text
  4. Click the alignment dropdown and select "Center" (or any alignment option)

Expected Behavior:
The selected text should be aligned to the center without errors.

Actual Behavior:
A JavaScript error is thrown:

The alignment is not applied, and the dropdown does not update.

Root Cause:
The align plugin in plugins.pkgd.min.js appears to call selectedCells() (a table plugin method) without checking if the table plugin is loaded or if the context is actually a table cell.

Workaround:
Adding the "table" plugin to pluginsEnabled alongside "align" resolves the issue:

Suggested Fix:
The align plugin should either:

  • Check if selectedCells exists before calling it
  • Document that the "table" plugin is a required dependency when using "align"
  • Separate text alignment logic from table cell alignment logic
  • Environment:

Browser: latest Chrome
Using: angular-froala-wysiwyg 4.6.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions