diff --git a/components/slide-renderer/components/element/TableElement/StaticTable.tsx b/components/slide-renderer/components/element/TableElement/StaticTable.tsx
index 186d346..a8394f1 100644
--- a/components/slide-renderer/components/element/TableElement/StaticTable.tsx
+++ b/components/slide-renderer/components/element/TableElement/StaticTable.tsx
@@ -95,47 +95,64 @@ export function StaticTable({ elementInfo }: StaticTableProps) {
))}
- {tableData.map((row, rowIdx) => (
-
- {(Array.isArray(row) ? row : []).map((cell, colIdx) => {
- if (hiddenCells.has(`${rowIdx}_${colIdx}`)) return null;
- if (!cell) return null;
+ {tableData.map((row, rowIdx) => {
+ const rowHeight = Number.isFinite(tableRowHeights[rowIdx])
+ ? tableRowHeights[rowIdx]
+ : safeCellMinHeight;
- const bgColor = getCellBg(rowIdx, colIdx, cell.style?.backcolor);
- const headerColor = getHeaderTextColor(rowIdx);
- const textStyle = getTextStyle(cell.style);
- const colspan = Number.isFinite(cell.colspan) && cell.colspan > 0 ? cell.colspan : 1;
- const rowspan = Number.isFinite(cell.rowspan) && cell.rowspan > 0 ? cell.rowspan : 1;
+ return (
+
+ {(Array.isArray(row) ? row : []).map((cell, colIdx) => {
+ if (hiddenCells.has(`${rowIdx}_${colIdx}`)) return null;
+ if (!cell) return null;
- // Header text color should be overridden only if cell doesn't have its own color
- if (headerColor && !cell.style?.color) {
- textStyle.color = headerColor;
- }
+ const bgColor = getCellBg(rowIdx, colIdx, cell.style?.backcolor);
+ const headerColor = getHeaderTextColor(rowIdx);
+ const textStyle = getTextStyle(cell.style);
+ const colspan =
+ Number.isFinite(cell.colspan) && cell.colspan > 0 ? cell.colspan : 1;
+ const rowspan =
+ Number.isFinite(cell.rowspan) && cell.rowspan > 0 ? cell.rowspan : 1;
- return (
- | 1 ? colspan : undefined}
- rowSpan={rowspan > 1 ? rowspan : undefined}
- style={{
- border: borderStyle,
- backgroundColor: bgColor,
- padding: '5px',
- verticalAlign: 'middle',
- wordBreak: 'break-word',
- ...textStyle,
- }}
- dangerouslySetInnerHTML={{ __html: formatText(cell.text) }}
- />
- );
- })}
- |
- ))}
+ // Header text color should be overridden only if cell doesn't have its own color
+ if (headerColor && !cell.style?.color) {
+ textStyle.color = headerColor;
+ }
+
+ return (
+ 1 ? colspan : undefined}
+ rowSpan={rowspan > 1 ? rowspan : undefined}
+ style={{
+ border: borderStyle,
+ backgroundColor: bgColor,
+ wordBreak: 'break-word',
+ ...textStyle,
+ }}
+ >
+
+ |
+ );
+ })}
+
+ );
+ })}
);
diff --git a/e2e/tests/table-playback-clipping-1365.spec.ts b/e2e/tests/table-playback-clipping-1365.spec.ts
new file mode 100644
index 0000000..0713ea4
--- /dev/null
+++ b/e2e/tests/table-playback-clipping-1365.spec.ts
@@ -0,0 +1,223 @@
+import type { Locator, Page } from '@playwright/test';
+import { test, expect } from '../fixtures/base';
+import { createSettingsStorage } from '../fixtures/test-data/settings';
+import { defaultTheme } from '../fixtures/test-data/scene-content';
+
+const STAGE_ID = 'e2e-table-clipping-1365';
+const FINAL_ROW_TEXT = 'Issue1365FinalRow';
+const SETTINGS_STORAGE = createSettingsStorage({ sidebarCollapsed: false });
+
+// At this width every first-column cell wraps to two lines. The element height
+// sits between the old legacy table (~266px) and both aligned renderers (~146px).
+const TABLE_WIDTH = 600;
+const TABLE_HEIGHT = 180;
+const TABLE_TOP = 370;
+const TABLE_ROTATE = 0;
+const ROW_TEXTS = [
+ '课堂播放渲染链与缩略图渲染链必须在同一份幻灯片数据上给出一致的表格高度',
+ '当单元格文本折行时旧实现的内边距与行高会把整张表格撑出元素盒子之外',
+ '本行用于验证表格底部内容在教室视图中不会被幻灯片视口裁掉的回归场景',
+ '两个渲染实现的行高都应由该行最高的单元格决定而不是由声明高度决定',
+ '最后一行是报告者截图里丢失的那一行必须在两条渲染链中完整可见',
+];
+
+async function seedTableClassroom(page: Page) {
+ await page.addInitScript(
+ ({ settings }) => {
+ localStorage.setItem('maic:account:settings-storage', settings);
+ localStorage.setItem('locale', 'en-US');
+ },
+ { settings: SETTINGS_STORAGE },
+ );
+
+ await page.goto('/', { waitUntil: 'networkidle' });
+
+ await page.evaluate(
+ ({ stageId, finalRowText, rowTexts, theme, geometry }) =>
+ new Promise((resolve, reject) => {
+ const request = indexedDB.open('MAIC-Database');
+
+ request.onsuccess = (event) => {
+ const db = (event.target as IDBOpenDBRequest).result;
+ const tx = db.transaction(['stages', 'scenes', 'stageOutlines'], 'readwrite');
+ const now = Date.now();
+
+ tx.objectStore('stages').put({
+ id: stageId,
+ name: 'Table clipping regression',
+ description: '',
+ language: 'zh-CN',
+ style: 'professional',
+ createdAt: now,
+ updatedAt: now,
+ });
+
+ tx.objectStore('scenes').put({
+ id: 'scene-table',
+ stageId,
+ type: 'slide',
+ title: 'Table clipping regression',
+ order: 0,
+ content: {
+ type: 'slide',
+ canvas: {
+ id: 'slide-table',
+ viewportSize: 1000,
+ viewportRatio: 0.5625,
+ background: { type: 'solid', color: '#ffffff' },
+ theme,
+ elements: [
+ {
+ id: 'table-near-bottom',
+ type: 'table',
+ left: 50,
+ top: geometry.top,
+ width: geometry.width,
+ height: geometry.height,
+ rotate: geometry.rotate,
+ colWidths: [0.5, 0.5],
+ rowHeights: [20, 20, 20, 20, 20],
+ cellMinHeight: 20,
+ outline: { width: 1, color: '#334155', style: 'solid' },
+ data: rowTexts.map((text, rowIndex) => [
+ {
+ id: `label-${rowIndex}`,
+ colspan: 1,
+ rowspan: 1,
+ text,
+ style: { fontsize: '14px' },
+ },
+ {
+ id: `value-${rowIndex}`,
+ colspan: 1,
+ rowspan: 1,
+ text:
+ rowIndex === rowTexts.length - 1 ? finalRowText : `Value${rowIndex + 1}`,
+ style: { fontsize: '14px' },
+ },
+ ]),
+ },
+ ],
+ },
+ },
+ createdAt: now,
+ updatedAt: now,
+ });
+
+ tx.objectStore('stageOutlines').put({
+ stageId,
+ outlines: [],
+ createdAt: now,
+ updatedAt: now,
+ });
+
+ tx.oncomplete = () => {
+ db.close();
+ resolve();
+ };
+ tx.onerror = () => reject(tx.error);
+ };
+ request.onerror = () => reject(request.error);
+ }),
+ {
+ stageId: STAGE_ID,
+ finalRowText: FINAL_ROW_TEXT,
+ rowTexts: ROW_TEXTS,
+ theme: defaultTheme,
+ geometry: {
+ top: TABLE_TOP,
+ width: TABLE_WIDTH,
+ height: TABLE_HEIGHT,
+ rotate: TABLE_ROTATE,
+ },
+ },
+ );
+}
+
+async function readSurface(locator: Locator) {
+ await expect(locator).toHaveCount(1);
+
+ return locator.evaluate((element) => {
+ const table = element.querySelector('table');
+ if (!table) throw new Error('Could not resolve the rendered HTML table');
+
+ const rows = Array.from(table.querySelectorAll('tr'));
+ const finalRow = rows.at(-1);
+ if (!finalRow) throw new Error('Could not resolve the final table row');
+
+ const wrappedRowCount = rows.filter((row) =>
+ Array.from(row.querySelectorAll('td')).some((cell) => {
+ const walker = document.createTreeWalker(cell, NodeFilter.SHOW_TEXT);
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
+ if (!node.textContent?.trim()) continue;
+ const range = document.createRange();
+ range.selectNodeContents(node);
+ const fragments = Array.from(range.getClientRects()).filter(
+ (rect) => rect.width > 0 && rect.height > 0,
+ );
+ if (fragments.length >= 2) return true;
+ }
+ return false;
+ }),
+ ).length;
+
+ const elementRect = element.getBoundingClientRect();
+ const tableRect = table.getBoundingClientRect();
+ const finalRowRect = finalRow.getBoundingClientRect();
+ const overflowRatio = (bottom: number) =>
+ Math.max(0, bottom - elementRect.bottom) / elementRect.height;
+
+ return {
+ rowCount: rows.length,
+ wrappedRowCount,
+ finalRowHeight: finalRowRect.height,
+ tableOverflowRatio: overflowRatio(tableRect.bottom),
+ finalRowOverflowRatio: overflowRatio(finalRowRect.bottom),
+ };
+ });
+}
+
+test('keeps wrapped table rows visible in the thumbnail and default classroom canvas', async ({
+ page,
+}, testInfo) => {
+ expect(TABLE_ROTATE, 'bounding-box assertions require an unrotated fixture').toBe(0);
+
+ await seedTableClassroom(page);
+ await page.goto(`/classroom/${STAGE_ID}`);
+ await page.getByText('Loading classroom...').waitFor({ state: 'hidden', timeout: 15_000 });
+
+ const legacyTable = page
+ .locator('.screen-element .base-element-table')
+ .filter({ hasText: FINAL_ROW_TEXT });
+ const thumbnailTable = page
+ .locator('.thumbnail-slide .base-element-table')
+ .filter({ hasText: FINAL_ROW_TEXT });
+ const surfaces = {
+ legacy: await readSurface(legacyTable),
+ package: await readSurface(thumbnailTable),
+ };
+
+ await testInfo.attach('table clipping metrics', {
+ body: JSON.stringify(surfaces, null, 2),
+ contentType: 'application/json',
+ });
+ await testInfo.attach('table clipping classroom', {
+ body: await page.screenshot(),
+ contentType: 'image/png',
+ });
+
+ for (const [name, surface] of Object.entries(surfaces)) {
+ expect(surface.rowCount, `${name}: row count`).toBe(ROW_TEXTS.length);
+ expect(surface.wrappedRowCount, `${name}: wrapped row count`).toBe(ROW_TEXTS.length);
+ expect(surface.finalRowHeight, `${name}: final row has visible geometry`).toBeGreaterThan(0);
+ expect(surface.tableOverflowRatio, `${name}: table escapes its element`).toBeLessThanOrEqual(
+ 0.01,
+ );
+ expect(
+ surface.finalRowOverflowRatio,
+ `${name}: final row escapes its element`,
+ ).toBeLessThanOrEqual(0.01);
+ }
+
+ expect(surfaces.package.rowCount).toBe(surfaces.legacy.rowCount);
+});
diff --git a/skills/agent-runtime/slide-dsl/SKILL.md b/skills/agent-runtime/slide-dsl/SKILL.md
index db1a1ba..ffac8df 100644
--- a/skills/agent-runtime/slide-dsl/SKILL.md
+++ b/skills/agent-runtime/slide-dsl/SKILL.md
@@ -298,8 +298,8 @@ always the same: **write for the intersection.** The known divergences are
playback (see [the HTML section](#the-rendering-truth-of-content-html));
- **`paragraphSpace` on a text element** — honoured by the preview renderer, inert
in playback;
-- **`vAlign` on a text element and `vAlign` / `padding` / `borders` on a table
- cell** — honoured by the preview renderer, ignored in playback;
+- **`vAlign` on a text element and per-side `borders` on a table cell** — honoured
+ by the preview renderer, ignored in playback;
- **a plain-text `content` with newlines** — the preview renderer sets
`white-space: pre-line` when the string contains no markup at all, so the
newlines become line breaks; playback does not, so they collapse to spaces;
@@ -529,7 +529,7 @@ geometry.
| --------------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| `colWidths` | number[] | **Ratios that sum to 1.** Column px = `colWidths[i] × element width` |
| `cellMinHeight` | number (px) | Row height fallback; content taller than it still expands the row |
-| `rowHeights` | number[] (optional) | Per-row height, overriding `cellMinHeight` for that row |
+| `rowHeights` | number[] (optional) | Per-row minimum, overriding `cellMinHeight`; wrapped content can expand it |
| `outline` | `{ style?, width?, color? }` | The uniform grid border. Missing `width` → **1 px**, missing `color` → **black** |
| `theme` | `{ color, rowHeader, rowFooter, colHeader, colFooter }` (optional) | Banding — see below |
| `data` | `TableCell[][]` | Row-major grid |
@@ -555,8 +555,9 @@ becomes ` `**. That has three consequences you must design around:
becomes `style="color: red"`, which is not a valid declaration, so the colour
is dropped. Same for any attribute value with a space in it, and for a
two-class `class`. Cell appearance comes from `cell.style`, not from markup.
-3. Text with spaces will **not wrap** at those spaces. Long prose in a cell
- overflows sideways instead of re-flowing.
+3. Text with spaces will **not wrap** at those spaces. Playback's
+ `word-break: break-word` can still re-flow long prose, but it may break in the
+ middle of a word instead of at the spaces as the preview renderer does.
So: put plain text in a cell, use `\n` for breaks, use `cell.style` for appearance,
and reach for attribute-free tags (``, `
`) only if you must. The preview
@@ -568,9 +569,15 @@ white text; `rowFooter` does the same to the last row; `colHeader` / `colFooter`
paint the first / last column in `theme.color` at 30 % alpha; every other even row
gets it at 10 %. A cell's own `style.backcolor` and `style.color` beat all of it.
-**Fields playback ignores** (preview renderer honours them): `cell.vAlign` —
-playback always centres vertically; `cell.padding` — playback always uses 5 px;
-`cell.borders` — playback always draws the table-level `outline` on all four sides.
+**Field playback ignores** (preview renderer honours it): `cell.borders` — playback
+always draws the table-level `outline` on all four sides. Both renderers honour
+`cell.padding`. `cell.vAlign` only aligns text inside the declared row-height
+content box; if the browser stretches the row, that box remains centred in the
+full cell.
+
+`cell.padding` has no implicit default: omit it for no inset, or provide a CSS
+padding string such as `5px` or `3px 6px`. Both renderers use `line-height: 1`
+for cell text.
**Merged cells are fragile.** Both renderers expect `data[r]` to contain only the
top-left cell of each merge, with the spanned positions absent, and playback's
diff --git a/tests/slide-renderer/edit-elements-render-contract.test.ts b/tests/slide-renderer/edit-elements-render-contract.test.ts
index 9a089a6..827a932 100644
--- a/tests/slide-renderer/edit-elements-render-contract.test.ts
+++ b/tests/slide-renderer/edit-elements-render-contract.test.ts
@@ -111,7 +111,7 @@ describe('edit_elements renderer contracts', () => {
}
});
- it('renders explicit table row heights in the app renderer', () => {
+ it('uses the same compact table cell geometry in both renderers', () => {
const table = {
id: 'table-1',
type: 'table',
@@ -120,15 +120,25 @@ describe('edit_elements renderer contracts', () => {
width: 200,
height: 100,
rotate: 0,
- data: [[{ id: 'a', text: 'A' }], [{ id: 'b', text: 'B' }]],
+ data: [
+ [{ id: 'a', text: 'A', padding: '2px 4px', vAlign: 'bottom' }],
+ [{ id: 'b', text: 'B' }],
+ ],
colWidths: [1],
rowHeights: [20, 80],
cellMinHeight: 36,
outline: { width: 1, color: '#000000' },
} as PPTTableElement;
- const markup = renderToStaticMarkup(React.createElement(StaticTable, { elementInfo: table }));
- expect(markup).toContain('height:20px');
- expect(markup).toContain('height:80px');
+ for (const Component of [StaticTable, PackageStaticTable]) {
+ const markup = renderToStaticMarkup(React.createElement(Component, { elementInfo: table }));
+ expect(markup).toContain('height:20px');
+ expect(markup).toContain('height:80px');
+ expect(markup).toContain('min-height:16px');
+ expect(markup).toContain('padding:2px 4px');
+ expect(markup).toContain('line-height:1');
+ expect(markup).toContain('justify-content:flex-end');
+ expect(markup).not.toContain('padding:5px');
+ }
});
it('fills the element height in the package table fallback path', () => {