diff --git a/public/stand.html b/public/stand.html
index ff2791ca3..d820afce7 100644
--- a/public/stand.html
+++ b/public/stand.html
@@ -62,6 +62,7 @@
Jodit Test Document
alert(111);
}
},
+ direction: 'rtl',
tabIndex: 0,
// shadowRoot: root,
// safeMode: true,
diff --git a/src/jodit.ts b/src/jodit.ts
index f7d8d0baa..d0319d472 100644
--- a/src/jodit.ts
+++ b/src/jodit.ts
@@ -1558,6 +1558,9 @@ export class Jodit extends ViewWithToolbar implements IJodit, Dlgs {
this.editor.style.direction = direction;
this.editor.setAttribute('dir', direction);
+ this.container.style.direction = direction;
+ this.container.setAttribute('dir', direction);
+
this.toolbar.setDirection(direction);
}
diff --git a/src/plugins/source/editor/engines/ace.ts b/src/plugins/source/editor/engines/ace.ts
index 97c8ca93e..89a774a32 100644
--- a/src/plugins/source/editor/engines/ace.ts
+++ b/src/plugins/source/editor/engines/ace.ts
@@ -115,6 +115,11 @@ export class AceEditor
this.instance = ace.edit(fakeMirror);
+ if (editor.o.direction === 'rtl') {
+ this.instance.setOption('rtlText', true);
+ this.instance.setOption('rtl', true);
+ }
+
this.instance.setTheme(editor.o.sourceEditorNativeOptions.theme);
this.instance.renderer.setShowGutter(
editor.o.sourceEditorNativeOptions.showGutter
diff --git a/src/plugins/source/editor/engines/area.ts b/src/plugins/source/editor/engines/area.ts
index 274341129..d1a6d33dc 100644
--- a/src/plugins/source/editor/engines/area.ts
+++ b/src/plugins/source/editor/engines/area.ts
@@ -25,7 +25,8 @@ export class TextAreaEditor
init(editor: IJodit): any {
this.instance = editor.c.element('textarea', {
- class: 'jodit-source__mirror'
+ class: 'jodit-source__mirror',
+ dir: editor.o.direction === 'rtl' ? 'rtl' : undefined
});
this.container.appendChild(this.instance);
diff --git a/test/tests/acceptance/interface.test.js b/test/tests/acceptance/interface.test.js
index 2d1c3991c..371c8e1ae 100644
--- a/test/tests/acceptance/interface.test.js
+++ b/test/tests/acceptance/interface.test.js
@@ -161,12 +161,27 @@ describe('Test interface', function () {
direction: 'rtl'
});
- expect('rtl').equals(editor.editor.getAttribute('dir'));
- expect('rtl').equals(editor.container.getAttribute('dir'));
- expect('rtl').equals(
- editor.toolbar.container.getAttribute('dir')
+ expect(editor.editor.getAttribute('dir')).equals('rtl');
+ expect(editor.container.getAttribute('dir')).equals('rtl');
+ expect(editor.toolbar.container.getAttribute('dir')).equals(
+ 'rtl'
);
});
+
+ describe('Source editor', function () {
+ it('Should have RTL direction', function () {
+ const editor = getJodit({
+ direction: 'rtl',
+ sourceEditor: 'area'
+ });
+ clickButton('source', editor);
+ expect(
+ editor.container
+ .querySelector('.jodit-source__mirror')
+ .getAttribute('dir')
+ ).equals('rtl');
+ });
+ });
});
describe('For iframe mode', function () {