Skip to content

Editor.commands type doesn't include some superdoc extension commands (createDocumentSection, updateSectionById, etc.) #2096

@Clstialdev

Description

@Clstialdev

Package: superdoc + @superdoc-dev/react

Problem

editor.commands.updateSectionById(), createDocumentSection(), and other extension commands work at runtime but aren't on the public Editor type. TypeScript reports "Cannot invoke an object which is possibly 'undefined'" because the exported EditorCommands uses an index signature that makes every command | undefined, and doesn't list the extension commands.

Here is the line that is used to infer the type of any 'other' command including these ones:
in superdoc-editor/src/index.d.ts

  // Allow any other command (for extension commands)
  [commandName: string]: ((...args: any[]) => boolean) | undefined;

Expected

  • editor.commands.updateSectionById({ id, html }) (and other extension commands) are typed and not possibly undefined.

Actual

  • Extension commands are missing from the public EditorCommands type and are treated as possibly undefined.

Steps to reproduce

No response

SuperDoc version

1.14.0

Browser

None

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions