Skip to content

Commit f2e1650

Browse files
authored
Merge pull request #1 from Bregor/feat/table-cells-overflow
feat: add configurable overflow-wrap for table cells
2 parents 673bc57 + de66658 commit f2e1650

3 files changed

Lines changed: 54 additions & 13 deletions

File tree

src/modules/_vars.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
--vcw-set-callout-scale: 1.2; /* Callouts narrower than body text */
1717
--vcw-set-padding-scale: 1; /* Multiplier for padding in wide mode */
1818
--vcw-set-table-scale: 1; /* Multiplier for table width in wide mode */
19+
20+
--vcw-set-table-head-overflow-wrap: break-word; /* Overflow wrap style for table head cells */
21+
--vcw-set-table-body-overflow-wrap: break-word; /* Overflow wrap style for table body cells */
1922
}
2023

2124
/* -------------------------------
@@ -133,6 +136,28 @@ settings:
133136
max: 2
134137
step: 0.05
135138
139+
- id: vcw-set-table-body-overflow-wrap
140+
title: Table body overflow wrap
141+
description: "How long words wrap in table body cells. break-word: breaks words only if needed (recommended), normal: breaks only at spaces, anywhere: breaks at any character"
142+
type: variable-select
143+
scope: root
144+
default: break-word
145+
options:
146+
- break-word
147+
- normal
148+
- anywhere
149+
150+
- id: vcw-set-table-head-overflow-wrap
151+
title: Table head overflow wrap
152+
description: "How long words wrap in table header cells. break-word: breaks words only if needed (recommended), normal: breaks only at spaces, anywhere: breaks at any character"
153+
type: variable-select
154+
scope: root
155+
default: break-word
156+
options:
157+
- break-word
158+
- normal
159+
- anywhere
160+
136161
- id: vcw-advanced-heading
137162
title: Advanced
138163
description: Fine-tune spacing and layout behavior

src/modules/preview.css

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,29 @@
1515
*/
1616
@container preview-readable (min-width: 0) {
1717
div.el-table {
18+
/* Table wrapper */
1819
margin-inline: var(--container-table-margin) !important;
1920
max-width: var(--container-table-max-width);
2021
min-width: var(--vcw-set-min-width);
2122
width: var(--container-table-width);
2223
padding-inline: 0 !important;
23-
}
24-
div.el-table > table {
25-
margin-inline: var(--table-margin) !important;
26-
max-width: var(--table-max-width);
27-
min-width: var(--table-min-width);
28-
table-layout: auto;
29-
width: var(--table-width);
30-
padding-inline: 0 !important;
24+
& > table {
25+
/* Table */
26+
margin-inline: var(--table-margin) !important;
27+
max-width: var(--table-max-width);
28+
min-width: var(--table-min-width);
29+
table-layout: auto;
30+
width: var(--table-width);
31+
padding-inline: 0 !important;
32+
& > thead > tr > th {
33+
/* Table header cells */
34+
overflow-wrap: var(--vcw-set-table-head-overflow-wrap);
35+
}
36+
& > tbody > tr > td {
37+
/* Table data cells */
38+
overflow-wrap: var(--vcw-set-table-body-overflow-wrap);
39+
}
40+
}
3141
}
3242

3343
div.el-h1 {

src/modules/source.css

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@
2929
padding-inline: 0 !important;
3030
max-width: var(--table-max-width);
3131
margin-inline: auto;
32-
}
33-
.table-wrapper > .table-editor {
34-
max-width: var(--table-max-width);
35-
width: var(--table-width);
36-
margin-inline: 0 !important;
32+
& > table.table-editor {
33+
max-width: var(--table-max-width);
34+
width: var(--table-width);
35+
margin-inline: 0 !important;
36+
& > thead > tr > th > .table-cell-wrapper {
37+
overflow-wrap: var(--vcw-set-table-head-overflow-wrap);
38+
}
39+
& > tbody > tr > td > .table-cell-wrapper {
40+
overflow-wrap: var(--vcw-set-table-body-overflow-wrap);
41+
}
42+
}
3743
}
3844
}
3945

0 commit comments

Comments
 (0)