Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/core/src/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,13 @@ export class Editor extends EventEmitter<EditorEvents> {
* @param handlePlugins Control how to merge the plugin into the existing plugins.
* @returns The new editor state
*/
public registerPlugin(
plugin: Plugin,
handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[],
public registerPlugin<T extends Plugin | Plugin[]>(
plugin: T,
handlePlugins?: (newPlugin: T, plugins: Plugin[]) => Plugin[],
Comment on lines +358 to +360
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handlePlugins callback parameter type may be confusing when T is Plugin[]. Consider using a more explicit type like (newPlugin: Plugin | Plugin[], plugins: Plugin[]) => Plugin[] to clarify that the callback receives the same input type as the method parameter.

Suggested change
public registerPlugin<T extends Plugin | Plugin[]>(
plugin: T,
handlePlugins?: (newPlugin: T, plugins: Plugin[]) => Plugin[],
public registerPlugin(
plugin: Plugin | Plugin[],
handlePlugins?: (newPlugin: Plugin | Plugin[], plugins: Plugin[]) => Plugin[],

Copilot uses AI. Check for mistakes.
): EditorState {
const plugins = isFunction(handlePlugins)
? handlePlugins(plugin, [...this.state.plugins])
: [...this.state.plugins, plugin]
: [...this.state.plugins, ...(Array.isArray(plugin) ? plugin : [plugin])]

const state = this.state.reconfigure({ plugins })

Expand Down
Loading