This commit is contained in:
1 parent
71c59837eb
commit
3c628e404d
2 files changed
+10
-4
No files matched your search
+1
-1
@@ -672,7 +672,7 @@ body.single-col .post-list {
|
|||||||
.article-content th,
|
.article-content th,
|
||||||
.article-content td {
|
.article-content td {
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
padding: 0.6rem 1rem;
|
padding: 0.3rem 0.8rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.article-content th {
|
.article-content th {
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ class TablePreviewWidget extends WidgetType {
|
|||||||
// Basic markdown parsing for links and strong could be done here, but textContent is safer
|
// Basic markdown parsing for links and strong could be done here, but textContent is safer
|
||||||
td.textContent = col;
|
td.textContent = col;
|
||||||
td.style.border = '1px solid var(--border-color, #e5e7eb)';
|
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';
|
td.style.textAlign = alignments[colIndex] || 'left';
|
||||||
if (isHeader) {
|
if (isHeader) {
|
||||||
td.style.backgroundColor = 'rgba(0, 0, 0, 0.03)';
|
td.style.backgroundColor = 'rgba(0, 0, 0, 0.03)';
|
||||||
@@ -266,14 +266,20 @@ function getTableDecorations(state: EditorState) {
|
|||||||
node.to === currentTableRange.to;
|
node.to === currentTableRange.to;
|
||||||
|
|
||||||
if (!isCurrent) {
|
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
|
// Skip malformed tables or empty ones
|
||||||
if (tableStr.trim().length > 0) {
|
if (tableStr.trim().length > 0) {
|
||||||
const deco = Decoration.replace({
|
const deco = Decoration.replace({
|
||||||
widget: new TablePreviewWidget(tableStr),
|
widget: new TablePreviewWidget(tableStr),
|
||||||
block: true
|
block: true
|
||||||
});
|
});
|
||||||
widgets.push(deco.range(node.from, node.to));
|
widgets.push(deco.range(from, to));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user