Skip to content

Commit 2fcce27

Browse files
committed
Fix(bidi): Fix for bug /codemirror/issues/4897
Fix for bug codemirror#4897
1 parent d02b119 commit 2fcce27

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

demo/bidi.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ <h2>Bi-directional Text Demo</h2>
6060
<input type="radio" id="ltr" name="direction"/><label for="ltr">LTR</label>
6161
<input type="radio" id="rtl" name="direction"/><label for="rtl">RTL</label>
6262
</fieldset>
63+
<fieldset>
64+
HTML document direction:
65+
<input type="radio" id="htmlltr" name="htmldirection"/><label for="htmlltr">LTR</label>
66+
<input type="radio" id="htmlrtl" name="htmldirection"/><label for="htmlrtl">RTL</label>
67+
</fieldset>
6368
<fieldset>
6469
<input type="checkbox" id="rtlMoveVisually"/><label for="rtlMoveVisually">Use visual order for arrow key movement.</label>
6570
</fieldset>
@@ -80,6 +85,13 @@ <h2>Bi-directional Text Demo</h2>
8085
editor.setOption("direction", dirRadios["rtl"].checked ? "rtl" : "ltr");
8186
};
8287

88+
var HtmlDirRadios = {ltr: document.getElementById("htmlltr"),
89+
rtl: document.getElementById("htmlrtl")};
90+
HtmlDirRadios["ltr"].checked = true;
91+
HtmlDirRadios["rtl"].onchange = HtmlDirRadios["ltr"].onchange = function() {
92+
document.dir = (HtmlDirRadios["rtl"].checked ? "rtl" : "ltr");
93+
};
94+
8395
var moveCheckbox = document.getElementById("rtlMoveVisually");
8496
moveCheckbox.checked = editor.getOption("rtlMoveVisually");
8597
moveCheckbox.onchange = function() {

lib/codemirror.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
font-family: monospace;
66
height: 300px;
77
color: black;
8+
direction: ltr;
89
}
910

1011
/* PADDING */

0 commit comments

Comments
 (0)