Skip to content

fix(types): type contextMenu.customItems as ContextMenuSection[] (SD-2514)#2777

Merged
caio-pizzol merged 3 commits intomainfrom
caio/sd-2514-fix-any-type-for-contextmenucustomitems-in-typescript
Apr 10, 2026
Merged

fix(types): type contextMenu.customItems as ContextMenuSection[] (SD-2514)#2777
caio-pizzol merged 3 commits intomainfrom
caio/sd-2514-fix-any-type-for-contextmenucustomitems-in-typescript

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

contextMenu.customItems was typed as bare {Array} which resolved to any[] in TypeScript. Define proper typedefs derived from runtime usage in the context menu component:

  • ContextMenuItem β€” id, label, icon, action, showWhen, render, shortcut
  • ContextMenuSection β€” id + items array
  • ContextMenuConfig β€” customItems, menuProvider, includeDefaultItems

Also replaces the flat {Object} / {Function} / {boolean} properties on contextMenu with a single {ContextMenuConfig} reference, and exports all three types from the superdoc barrel.

Consumer-typecheck regression test added.

Resolves SD-2514

@linear
Copy link
Copy Markdown

linear bot commented Apr 10, 2026

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

πŸ’‘ 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.
@caio-pizzol caio-pizzol force-pushed the caio/sd-2514-fix-any-type-for-contextmenucustomitems-in-typescript branch from 913e8a4 to 91c8c02 Compare April 10, 2026 22:50
@caio-pizzol caio-pizzol enabled auto-merge April 10, 2026 22:50
@caio-pizzol caio-pizzol added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit 0f00522 Apr 10, 2026
50 of 53 checks passed
@caio-pizzol caio-pizzol deleted the caio/sd-2514-fix-any-type-for-contextmenucustomitems-in-typescript branch April 10, 2026 22:58
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

πŸŽ‰ This PR is included in @superdoc-dev/react v1.1.1-next.1

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

πŸŽ‰ This PR is included in vscode-ext v2.3.0-next.1

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

πŸŽ‰ This PR is included in template-builder v1.5.0-next.1

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

πŸŽ‰ This PR is included in esign v2.3.0-next.1

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

πŸŽ‰ This PR is included in superdoc-cli v0.7.0-next.1

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

πŸŽ‰ This PR is included in superdoc v1.26.0-next.1

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

πŸŽ‰ This PR is included in superdoc-sdk v1.5.1-next.1

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 11, 2026

πŸŽ‰ This PR is included in @superdoc-dev/react v1.1.1

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 11, 2026

πŸŽ‰ This PR is included in superdoc-sdk v1.5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant