fix(types): type contextMenu.customItems as ContextMenuSection[] (SD-2514)#2777
Conversation
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f743ce84e
βΉοΈ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
β¦2514)
contextMenu.customItems was typed as bare {Array} which resolved to any[]
in TypeScript. Define ContextMenuItem, ContextMenuSection, and
ContextMenuConfig typedefs with proper shapes derived from runtime usage
in the context menu component. Also types menuProvider callback signature.
action receives (editor, context), not just (editor). Extract ContextMenuContext typedef with the full runtime shape (isInTable, documentMode, activeMarks, etc.) and use it across showWhen, render, action, and menuProvider. Also simplify AugmentedChainedCommands to reuse Chainified<KnownCommandRecord> instead of restating the mapped type.
Runtime falls back to original sections when menuProvider returns falsy (menuProvider(...) || allSections), so the type should allow it.
913e8a4 to
91c8c02
Compare
|
π This PR is included in @superdoc-dev/react v1.1.1-next.1 The release is available on GitHub release |
|
π This PR is included in vscode-ext v2.3.0-next.1 |
|
π This PR is included in template-builder v1.5.0-next.1 The release is available on GitHub release |
|
π This PR is included in esign v2.3.0-next.1 The release is available on GitHub release |
|
π This PR is included in superdoc-cli v0.7.0-next.1 The release is available on GitHub release |
|
π This PR is included in superdoc v1.26.0-next.1 The release is available on GitHub release |
|
π This PR is included in superdoc-sdk v1.5.1-next.1 |
|
π This PR is included in @superdoc-dev/react v1.1.1 The release is available on GitHub release |
|
π This PR is included in superdoc-sdk v1.5.1 |
contextMenu.customItems was typed as bare
{Array}which resolved toany[]in TypeScript. Define proper typedefs derived from runtime usage in the context menu component:ContextMenuItemβ id, label, icon, action, showWhen, render, shortcutContextMenuSectionβ id + items arrayContextMenuConfigβ customItems, menuProvider, includeDefaultItemsAlso replaces the flat
{Object}/{Function}/{boolean}properties oncontextMenuwith a single{ContextMenuConfig}reference, and exports all three types from the superdoc barrel.Consumer-typecheck regression test added.
Resolves SD-2514