Skip to content

feat: extend tiptap table to have a (configurable) class attribute #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fsbraun
Copy link
Member

@fsbraun fsbraun commented Apr 10, 2025

Fixes #78

This PR allows to add class attributes to tables.

Summary by Sourcery

Extend Tiptap table extension to support configurable class attributes for tables

New Features:

  • Add ability to specify custom CSS classes for tables in the Tiptap editor

Enhancements:

  • Create an ExtendedTable extension that allows individual tables to have custom CSS classes
  • Update table insertion logic to support class attribute

Chores:

  • Update Tiptap and development dependencies to latest versions

Copy link
Contributor

sourcery-ai bot commented Apr 10, 2025

Reviewer's Guide by Sourcery

This pull request extends the Tiptap table extension to allow for configurable class attributes. It introduces a new ExtendedTable extension that inherits from the base Table extension and adds the ability to parse and render a class attribute for the table. The toolbar and table insertion logic have been modified to support selecting and applying these classes. Additionally, development dependencies have been updated.

Sequence diagram for inserting a table with a class

sequenceDiagram
  participant Editor
  participant Toolbar
  participant Chain
  participant TableNode

  Toolbar->>Editor: User clicks table button with class
  Editor->>Chain: chain()
  Chain->>Chain: focus()
  Chain->>Chain: insertTable({rows, cols})
  Chain->>Chain: updateAttributes('table', {class})
  Chain->>Chain: run()
  Chain-->>TableNode: Creates and inserts table node with class attribute
  Editor-->>Toolbar: Updates editor view
Loading

Updated class diagram for the Table extension

classDiagram
  class Table {
    +resizable: boolean
    +HTMLAttributes: Object
  }
  class ExtendedTable {
    +attributes: Object
    +class: string|null
    +addAttributes()
  }
  Table <|-- ExtendedTable
  note for ExtendedTable "Allows individual tables to have custom CSS classes applied"
Loading

File-Level Changes

Change Details Files
Extended the Tiptap table extension to allow for configurable class attributes.
  • Created a new ExtendedTable extension that extends the base Table extension.
  • Added a class attribute to the table's attributes, allowing it to be parsed from and rendered to HTML.
  • Modified the toolbar to allow passing table classes.
  • Modified the table insertion logic to update the table attributes with the selected class.
private/js/tiptap_plugins/cms.table.js
private/js/tiptap_plugins/cms.tiptap.toolbar.js
private/js/cms.tiptap.js
Updated various development dependencies.
  • Updated @babel/core from ^7.26.9 to ^7.26.10.
  • Updated css-minimizer-webpack-plugin from ^7.0.0 to ^7.0.2.
  • Updated sass from ^1.85.1 to ^1.86.3.
  • Updated slim-select from ^2.10.0 to ^2.11.0.
  • Updated webpack from ^5.98.0 to ^5.99.5.
  • Updated @tiptap/core from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-blockquote from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-bubble-menu from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-character-count from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-floating-menu from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-image from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-link from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-placeholder from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-subscript from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-superscript from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-table from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-table-cell from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-table-header from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-table-row from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-text-align from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/extension-underline from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/pm from ^2.11.5 to ^2.11.7.
  • Updated @tiptap/starter-kit from ^2.11.5 to ^2.11.7.
package.json

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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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

Copy link

codecov bot commented Apr 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.30%. Comparing base (d914b8b) to head (0a5a6ad).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #76   +/-   ##
=======================================
  Coverage   81.30%   81.30%           
=======================================
  Files          18       18           
  Lines         952      952           
  Branches      107      107           
=======================================
  Hits          774      774           
  Misses        135      135           
  Partials       43       43           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Customize TipTap, esp. table
1 participant