Skip to content

Commit

Permalink
- Fixed rtl test
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan committed Nov 30, 2024
1 parent 756fbe3 commit 841e7e9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions public/stand.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ <h1>Jodit Test Document</h1>
alert(111);
}
},
direction: 'rtl',
tabIndex: 0,
// shadowRoot: root,
// safeMode: true,
Expand Down
3 changes: 3 additions & 0 deletions src/jodit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
5 changes: 5 additions & 0 deletions src/plugins/source/editor/engines/ace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/source/editor/engines/area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 19 additions & 4 deletions test/tests/acceptance/interface.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 841e7e9

Please sign in to comment.