Skip to content

Commit 47008cb

Browse files
authored
Merge pull request #72 from zoli/fix/table-rtl
fix: auto direction behavior on tables
2 parents d7cc25b + be9c180 commit 47008cb

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

AutoDirPostProcessor.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,10 @@ function dirClass(dir: Direction): string {
106106
}
107107

108108
function addDirClassIfNotAddedBefore(el: HTMLElement, cls: string) {
109-
if (el.hasClass('esm-rtl') || el.hasClass('esm-ltr')) {
110-
return;
109+
if (!el.hasClass(cls)) {
110+
el.removeClass('esm-rtl', 'esm-ltr');
111+
el.addClass(cls);
111112
}
112-
113-
el.addClass(cls);
114113
}
115114

116115
function nonSpecialParent(el: HTMLElement) {
@@ -119,4 +118,4 @@ function nonSpecialParent(el: HTMLElement) {
119118
}
120119

121120
return el;
122-
}
121+
}

styles.css

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
}
1717

1818
/* List indent fix */
19-
.is-mobile .is-rtl .HyperMD-list-line, .is-mobile .HyperMD-list-line[dir="rtl"] {
19+
.is-mobile .is-rtl .HyperMD-list-line,
20+
.is-mobile .HyperMD-list-line[dir="rtl"] {
2021
text-indent: 0px !important;
2122
padding-left: 0 !important;
2223
}
@@ -127,7 +128,8 @@
127128

128129
.markdown-preview-view.is-auto .esm-rtl,
129130
.kanban-plugin__board .esm-rtl,
130-
.kanban-plugin__drag-container .esm-rtl {
131+
.kanban-plugin__drag-container .esm-rtl,
132+
.markdown-source-view.is-auto .table-cell-wrapper.esm-rtl {
131133
direction: rtl;
132134
text-align: right;
133135
}
@@ -191,6 +193,17 @@ This the collapse indicator will be over the heading text */
191193
text-align-last: left;
192194
}
193195

196+
/* If table first header is rtl render table on the right side of page but dont
197+
* make every cell rtl*/
198+
.cm-table-widget:has(thead tr:first-of-type th:first-of-type .table-cell-wrapper.esm-rtl),
199+
.cm-table-widget:has(thead tr:first-of-type th:first-of-type .table-cell-wrapper .cm-line[dir="rtl"]) {
200+
direction: rtl;
201+
}
202+
.cm-table-widget:has(thead tr:first-of-type th:first-of-type .table-cell-wrapper.esm-rtl) .table-wrapper,
203+
.cm-table-widget:has(thead tr:first-of-type th:first-of-type .table-cell-wrapper .cm-line[dir="rtl"]) .table-wrapper {
204+
direction: ltr;
205+
}
206+
194207
/* Helper styles for debugging */
195208
/* .cm-line[dir="rtl"] { */
196209
/* border-right: dashed; */

0 commit comments

Comments
 (0)