Skip to content

feat(YfmTable): add background color picker to row and column controls#1126

Draft
d3m1d0v wants to merge 2 commits intomainfrom
d3m1d0v/table-cell-bg
Draft

feat(YfmTable): add background color picker to row and column controls#1126
d3m1d0v wants to merge 2 commits intomainfrom
d3m1d0v/table-cell-bg

Conversation

@d3m1d0v
Copy link
Copy Markdown
Member

@d3m1d0v d3m1d0v commented May 5, 2026

Adds cell background color support to YFM table controls. A new color palette appears in the row/column floating menu, applying the selected color to the entire row or column. Feature is gated behind a cellBackground option (requires @diplodoc/transform ≥ 4.75.0).

Summary by Sourcery

Introduce configurable cell background coloring for YFM table cells, wiring it into table controls, serialization, and styling while gating the feature behind a cellBackground option.

New Features:

  • Add optional cell background color support for YFM tables, including row/column menu controls and palette-based color selection.
  • Serialize and store cell background attributes for table cells so background colors round-trip through YFM markup.

Enhancements:

  • Propagate a cellBackground option through YFM table controls and focus plugin, and wire it into the demo playground configuration.
  • Style table cell background colors in the markdown editor theme and expose markdown-editor styles in demo storybook HOCs.

Tests:

  • Add (currently skipped) tests covering serialization of cell background attributes for various table cell positions.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 5, 2026

Reviewer's Guide

Adds gated support for setting and serializing per-cell background colors in YFM tables, with row/column palette controls, schema and serializer wiring, and demo styling.

File-Level Changes

Change Details Files
Add gated cell background color support to YFM table schema, DOM rendering, and serializer.
  • Introduce YfmTableAttr.CellBg and add it to the table cell node attributes in the schema.
  • Update the table cell NodeView to reflect CellBg on the
element via CSS classes and data attribute, cleaning up previous values on update.
  • Extend the YFM table serializer to emit ::{bg="..."} attributes for the first cell marker and subsequent cells when CellBg is present.
  • Add skipped tests that describe expected serialization of single and multiple cell background attributes once transform supports them.
  • packages/editor/src/extensions/yfm/YfmTable/YfmTableSpecs/const.ts
    packages/editor/src/extensions/yfm/YfmTable/YfmTableSpecs/schema.ts
    packages/editor/src/extensions/yfm/YfmTable/YfmTableSpecs/serializer.ts
    packages/editor/src/extensions/yfm/YfmTable/YfmTable.test.ts
    packages/editor/src/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.tsx
    Expose a row/column floating menu color palette that applies background colors across entire rows or columns via a ProseMirror command.
    • Add a setCellBg ProseMirror command using TableDesc helpers to set CellBg on a list of row or column cells in a transaction.
    • Wire new row and column handlers in the cell NodeView to call setCellBg across the current row or column and log analytics events.
    • Extend FloatingMenuControl to optionally show a nested CellBgPalette item when cellBackground is enabled, passing current cell color and change handler.
    • Implement the CellBgPalette React component and styles using @gravity-ui/uikit Palette and a fixed set of semantic background color options.
    • Ensure the focus/controls plugins accept and propagate the new cellBackground flag from the YfmTable extension options.
    packages/editor/src/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.tsx
    packages/editor/src/extensions/yfm/YfmTable/plugins/YfmTableControls/components/CellBgPalette/CellBgPalette.tsx
    packages/editor/src/extensions/yfm/YfmTable/plugins/YfmTableControls/components/CellBgPalette/CellBgPalette.scss
    packages/editor/src/extensions/yfm/YfmTable/plugins/YfmTableControls/components/CellBgPalette/colors.ts
    packages/editor/src/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.tsx
    packages/editor/src/extensions/yfm/YfmTable/plugins/YfmTableControls/commands/set-cell-bg.ts
    packages/editor/src/extensions/yfm/YfmTable/plugins/YfmTableControls/index.ts
    packages/editor/src/extensions/yfm/YfmTable/plugins/YfmTableControls/plugins/focus-plugin.ts
    Add configuration, demo wiring, and CSS for cell background feature and YFM table visuals.
    • Introduce a cellBackground option on the YfmTable extension, defaulting to disabled, and pass it into the controls plugins; enable it in the demo playground config.
    • Add yc-table.scss with td background color rules matching semantic CellBg values and include it from markdown.scss.
    • Ensure demo Storybook decorators import markdown.css so table styles (including cell backgrounds) are available.
    packages/editor/src/extensions/yfm/YfmTable/index.ts
    packages/editor/src/styles/markdown.scss
    packages/editor/src/styles/yc-table.scss
    demo/src/components/Playground.tsx
    demo/src/hocs/withLang.tsx
    demo/src/hocs/withThemeProvider.tsx
    demo/src/hocs/withToaster.tsx

    Tips and commands

    Interacting with Sourcery

    • Trigger a new review: Comment @sourcery-ai review on the pull request.
    • Continue discussions: Reply directly to Sourcery's review comments.
    • Generate a GitHub issue from a review comment: Ask Sourcery to create an
      issue from a review comment by replying to it. You can also reply to a
      review comment with @sourcery-ai issue to create an issue from it.
    • Generate a pull request title: Write @sourcery-ai anywhere in the pull
      request title to generate a title at any time. You can also comment
      @sourcery-ai title on the pull request to (re-)generate the title at any time.
    • Generate a pull request summary: Write @sourcery-ai summary anywhere in
      the pull request body to generate a PR summary at any time exactly where you
      want it. You can also comment @sourcery-ai summary on the pull request to
      (re-)generate the summary at any time.
    • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
      request to (re-)generate the reviewer's guide at any time.
    • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
      pull request to resolve all Sourcery comments. Useful if you've already
      addressed all the comments and don't want to see them anymore.
    • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
      request to dismiss all existing Sourcery reviews. Especially useful if you
      want to start fresh with a new review - don't forget to comment
      @sourcery-ai review to trigger a new review!

    Customizing Your Experience

    Access your dashboard to:

    • Enable or disable review features such as the Sourcery-generated pull request
      summary, the reviewer's guide, and others.
    • Change the review language.
    • Add, remove or edit custom review instructions.
    • Adjust other review settings.

    Getting Help

    @gravity-ui
    Copy link
    Copy Markdown

    gravity-ui Bot commented May 5, 2026

    Storybook Deployed

    @gravity-ui
    Copy link
    Copy Markdown

    gravity-ui Bot commented May 5, 2026

    🎭 Playwright Report

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

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants