diff --git a/CHANGELOG.md b/CHANGELOG.md index 9832d7f..638aae0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ and `MarkupString.Pueblo`. The packages share one version and are released toget The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 2.24.1 — Unreleased + +### Fixed + +- **A copied table keeps its rows**: a cell's text is no longer a block of its own, which a browser copied + as a line per cell. A cell that holds one text is laid out inline, so a copied row is its cells with tabs + between them. + ## 2.24.0 — Unreleased ### Added diff --git a/MarkupString.Html/LayoutCss.cs b/MarkupString.Html/LayoutCss.cs index aa51a86..2ae1aab 100644 --- a/MarkupString.Html/LayoutCss.cs +++ b/MarkupString.Html/LayoutCss.cs @@ -101,6 +101,9 @@ public static class LayoutCss ".ms-table { border-collapse: collapse; }\n" + ".ms-table.ms-fill { width: 100%; }\n" + ".ms-table th, .ms-table td { padding: 0 1ch; vertical-align: top; text-align: left; }\n" + + // A block inside a cell is copied as a line of its own, so a cell of one text is laid out inline: a copied + // row is its cells with tabs between, as a table with bare text in its cells copies. + ".ms-table :is(th, td) > .ms-text:only-child { display: inline-block; width: 100%; }\n" + ".ms-table th { border-bottom: 1px solid var(--ms-header-rule, var(--ms-header-rule-default, currentColor)); color: var(--ms-heading, var(--ms-heading-default, inherit)); }\n" + ".ms-table.ms-striped > tbody > tr:nth-child(even) { background: var(--ms-stripe, var(--ms-stripe-default, rgba(127, 127, 127, 0.12))); }\n" + ".ms-table .ms-nowrap, .ms-table .ms-nowrap .ms-text { white-space: pre; overflow-wrap: normal; }\n" + diff --git a/MarkupString.Tests/Layout/WidgetLayoutTests.cs b/MarkupString.Tests/Layout/WidgetLayoutTests.cs index 026c7a3..09366b0 100644 --- a/MarkupString.Tests/Layout/WidgetLayoutTests.cs +++ b/MarkupString.Tests/Layout/WidgetLayoutTests.cs @@ -187,6 +187,13 @@ public async Task Table_InHtml_KeepsAColumnThatDoesNotWrapOnOneLine() await Assert.That(LayoutCss.Fixed).Contains(".ms-table .ms-nowrap, .ms-table .ms-nowrap .ms-text { white-space: pre; overflow-wrap: normal; }"); } + [Test] + public async Task Table_InHtml_LaysACellsOneTextInline() + { + // A browser copies a block as a line of its own: a cell's only text inline keeps a copied row on one line. + await Assert.That(LayoutCss.Fixed).Contains(".ms-table :is(th, td) > .ms-text:only-child { display: inline-block; width: 100%; }"); + } + [Test] public async Task Table_InHtml_NoWrapWithoutPriority_HasOnlyItsClass() {