diff --git a/src/app.css b/src/app.css index 5622e56..77cb4d0 100644 --- a/src/app.css +++ b/src/app.css @@ -672,7 +672,7 @@ body.single-col .post-list { .article-content th, .article-content td { border: 1px solid var(--border-color); - padding: 0.6rem 1rem; + padding: 0.3rem 0.8rem; } .article-content th { diff --git a/src/lib/editor/tableFormatterPlugin.ts b/src/lib/editor/tableFormatterPlugin.ts index 0a81541..b3f3d95 100644 --- a/src/lib/editor/tableFormatterPlugin.ts +++ b/src/lib/editor/tableFormatterPlugin.ts @@ -223,7 +223,7 @@ class TablePreviewWidget extends WidgetType { // Basic markdown parsing for links and strong could be done here, but textContent is safer td.textContent = col; td.style.border = '1px solid var(--border-color, #e5e7eb)'; - td.style.padding = '0.6rem 1rem'; + td.style.padding = '0.3rem 0.8rem'; td.style.textAlign = alignments[colIndex] || 'left'; if (isHeader) { td.style.backgroundColor = 'rgba(0, 0, 0, 0.03)'; @@ -266,14 +266,20 @@ function getTableDecorations(state: EditorState) { node.to === currentTableRange.to; if (!isCurrent) { - const tableStr = state.doc.sliceString(node.from, node.to); + // Ensure block replace decorations cover entire lines + const startLine = state.doc.lineAt(node.from); + const endLine = state.doc.lineAt(node.to); + const from = startLine.from; + const to = endLine.to; + + const tableStr = state.doc.sliceString(from, to); // Skip malformed tables or empty ones if (tableStr.trim().length > 0) { const deco = Decoration.replace({ widget: new TablePreviewWidget(tableStr), block: true }); - widgets.push(deco.range(node.from, node.to)); + widgets.push(deco.range(from, to)); } } }