Skip to content

Commit 7ca0526

Browse files
committed
Version 1.2.0 with good table support
1 parent 47008cb commit 7ca0526

File tree

6 files changed

+48
-10
lines changed

6 files changed

+48
-10
lines changed

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2022 esm7
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ If you want to support the development of this plugin, please consider to [buy m
4040
Version 1.0.0 of this plugin introduced an "auto" mode that detects the direction of each line individually and enables mixed LTR/RTL in the same note.
4141
This mechanism is based on the "per line text direction" support for CodeMirror that was added a few months earlier, but it tweaks it extensively in order to reach the best user experience that we could (and thanks @zoli for being the first to figure out how to utilize this in an editor plugin!)
4242

43-
As of January 2023 when this is introduced, this feature should be regarded as experimental; it may not work perfectly in 100% of the cases.
43+
For tables, the direction of the table is decided based on the first cell of the table (left-most cell of the header for an LTR table or the right-most one for an RTL table).
4444

4545
## Settings
4646

@@ -79,6 +79,14 @@ It is possible to temporarily override a note's direction regardless of the fron
7979

8080
## Changelog
8181

82+
### 1.2.0
83+
84+
- Auto direction is now the default for new users installing the plugin.
85+
- Decent support for tables, thanks to the incredible @zoli:
86+
- Tables now properly obey to the document direction.
87+
- In auto direction, the table direction is decided based on the first cell of the table.
88+
- Mixed LTR-RTL tables are supported, but due to Obsidian's current cursor movement implementation, moving between cells with different directions using the keyboard arrows isn't great.
89+
8290
### 1.1.2
8391

8492
**Bug fixes:**

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-rtl",
33
"name": "RTL Support",
4-
"version": "1.1.2",
4+
"version": "1.2.0",
55
"minAppVersion": "0.15.3",
66
"description": "Right to Left (RTL) text direction support for languages like Arabic, Hebrew and Persian (Farsi).",
77
"author": "esm",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-rtl",
3-
"version": "1.1.2",
3+
"version": "1.2.0",
44
"description": "RTL (Right to Left) language support for Obsidian.",
55
"main": "main.js",
66
"scripts": {

settingsTab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type Settings = {
1313

1414
export const DEFAULT_SETTINGS: Settings = {
1515
fileDirections: {},
16-
defaultDirection: 'ltr',
16+
defaultDirection: 'auto',
1717
rememberPerFile: true,
1818
setNoteTitleDirection: true,
1919
setYamlDirection: false,

styles.css

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,25 @@ This the collapse indicator will be over the heading text */
193193
text-align-last: left;
194194
}
195195

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"]) {
196+
/* If the table first header cell is RTL render the table on the right side of page but dont make every cell RTL */
197+
.is-auto .cm-table-widget:has(thead tr:first-of-type th:first-of-type .table-cell-wrapper.esm-rtl),
198+
.is-auto .cm-table-widget:has(thead tr:first-of-type th:first-of-type .table-cell-wrapper .cm-line[dir="rtl"]) {
200199
direction: rtl;
201200
}
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 {
201+
.is-auto .cm-table-widget .table-cell-wrapper.esm-ltr {
202+
direction: ltr;
203+
}
204+
.is-auto .cm-table-widget:has(thead tr:first-of-type th:first-of-type .table-cell-wrapper.esm-rtl) .table-col-btn {
205+
left: -16px;
206+
border-left: inherit;
207+
cursor: w-resize;
208+
}
209+
210+
/* Similarly to the above, decide on the table direction for Reading View based on the first header cell */
211+
.markdown-preview-view.is-auto div:has(table thead tr:first-of-type th:first-of-type.esm-rtl) {
212+
direction: rtl;
213+
}
214+
.markdown-preview-view.is-auto div:has(table thead tr:first-of-type th:first-of-type.esm-ltr) {
204215
direction: ltr;
205216
}
206217

0 commit comments

Comments
 (0)