PRC's override/extension of the WordPress core/table block.
prc-block/core-table
- Adds
allowSortingandsortingOptionsattributes for DataTables-powered sortable tables - Allows CSV file uploads via the WordPress media library
- Provides a CSV Import panel in the editor sidebar with file input and drag-and-drop support
- Registers a "Plain Table" block style
- Handles legacy HTML tables with
prc-tableclass by migrating them towp-block-tableclasses - Initializes DataTables on sortable tables with searching/info/paging disabled
- Custom table styling with dotted borders and minimal visual treatment
None beyond custom attributes.
| Attribute | Type | Default | Description |
|---|---|---|---|
allowSorting |
boolean |
false |
Enables DataTables sorting on the table |
sortingOptions |
array |
-- | Configuration options for DataTables sorting |
Added via block_type_metadata filter in add_attributes.
| Style Name | Label | Description |
|---|---|---|
plain-table |
Plain Table | Inherits background color on tbody cells |
Registered in PHP via register_block_style with inline CSS.
File: style.scss
- Table base (
:not(.is-style-plain-table)) --color: black, inherited background - Caption --
font-size: 0.8em,color: #999,margin-top: 1.25em - Table element -- zero bottom border,
border-spacing: 2px - Thead -- zero bottom border;
thcells get white background, no borders, bold text, left-aligned - Tbody --
tdcells have no left/top/right borders,dottedbottom border in#ddd - Cell min-width --
4emon alltdelements - Legacy HTML tables --
.html-fallback-tableset tofont-size: 14px
File: index.js
- HOC wrapping
editor.BlockEditforcore/tableto inject theControlscomponent - Imports
style.scssfor editor/frontend styles
File: controls.jsx
- "CSV Import" inspector panel with:
- A
Buttonthat triggers a hidden file input for CSV selection - A
DropZonefor drag-and-drop CSV import - Both pass files to the
handleCSVparser
- A
File: csv-parser.js
- Parses CSV files using the
comma-separated-valueslibrary - Converts the first row to table head cells and remaining rows to table body cells
- Updates the block's
headandbodyattributes with the parsed data
File: view.js
- On DOM ready, initializes DataTable on all
.wp-block-table.sortable-tableelements - DataTable configuration:
searching: false,info: false,lengthChange: false,paging: false,responsive: true
File: class-core-table.php
add_attributes(block_type_metadatafilter) -- addsallowSortingandsortingOptionsattributesregister_assets(inithook) -- registers editor script, style, and view script handles; callsregister_new_stylesregister_new_styles-- registers theplain-tableblock styleallow_csv_mime_type(upload_mimesfilter) -- addstext/csvto allowed upload typesenqueue_view_style(render_blockfilter) -- handles two scenarios:- For
core/tableblocks: enqueues the style - For
core/htmlblocks containingprc-table: migrates class towp-block-table has-sans-serif-font-family html-fallback-table; ifdata-ordering="true"is present, addssortable-tableclass, generates a unique ID, and enqueues the DataTables view script and styles
- For
<!-- Standard table -->
<figure class="wp-block-table">
<table>
<thead>
<tr><th>Category</th><th>Percentage</th></tr>
</thead>
<tbody>
<tr><td>Group A</td><td>45%</td></tr>
<tr><td>Group B</td><td>55%</td></tr>
</tbody>
</table>
</figure>
<!-- Sortable table -->
<figure class="wp-block-table sortable-table" id="prc-sortable-table-1">
<table>
<thead>
<tr><th>Country</th><th>Value</th></tr>
</thead>
<tbody>
<tr><td>United States</td><td>72</td></tr>
<tr><td>Germany</td><td>68</td></tr>
</tbody>
</table>
</figure>None.