Skip to content

Commit

Permalink
Merge pull request #66 from ckeditor/i/64
Browse files Browse the repository at this point in the history
Fix: The inspector should render the RTL content in the trees properly. Closes #64.
  • Loading branch information
jodator committed Oct 24, 2019
2 parents c92124a + 8bf284d commit 40c3102
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 0 deletions.
22 changes: 22 additions & 0 deletions sample/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ <h2>Second editor</h2>
<p>foo</p>
</div>

<h2>RTL editor</h2>
<div id="rtl-editor-content">
<p>مرحبا</p>
<p>مرحبا</p>
<p>مرحبا</p>
</div>

<h2>Actions</h2>
<button id="attach-inspector">Attach inspector to all editors</button>
<button id="detach-inspector-from-editors">Detach inspector from editors</button>
Expand Down Expand Up @@ -124,6 +131,21 @@ <h2>Actions</h2>
.catch( error => {
console.error( error );
} );

DecoupledEditor
.create( document.querySelector( '#rtl-editor-content' ), {
extraPlugins: [ UploadAdapter ],
language: 'ar'
} )
.then( editor => {
window.secondEditor = editor;
document.body.insertBefore( editor.ui.view.toolbar.element, editor.ui.getEditableElement() );
const [ name ] = CKEditorInspector.attach( { 'rtl': editor } );
editorNames.push( name );
} )
.catch( error => {
console.error( error );
} );
</script>
</body>
<style>
Expand Down
1 change: 1 addition & 0 deletions src/components/model/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class ModelTree extends Component {
]}
<Tree
items={tree}
textDirection={this.props.editor.locale.contentLanguageDirection}
onClick={this.props.onClick}
showCompactText={this.state.showCompactText}
activeNode={this.props.currentEditorNode}
Expand Down
10 changes: 10 additions & 0 deletions src/components/tree.css
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@
}
}

/*-- LTR vs. RTL text ------------------------------------------------------------------------*/

.ck-inspector-tree.ck-inspector-tree_text-direction_ltr .ck-inspector-tree-node__content {
direction: ltr;
}

.ck-inspector-tree.ck-inspector-tree_text-direction_rtl .ck-inspector-tree-node__content {
direction: rtl;
}

/*-- Comment -----------------------------------------------------------------------------*/

.ck-inspector-tree .ck-inspector-tree-comment {
Expand Down
1 change: 1 addition & 0 deletions src/components/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default class Tree extends Component {

return <div className={[
'ck-inspector-tree',
this.props.textDirection ? 'ck-inspector-tree_text-direction_' + this.props.textDirection : '',
this.props.showCompactText ? 'ck-inspector-tree_compact-text' : ''
].join( ' ' )}>
{treeContent}
Expand Down
1 change: 1 addition & 0 deletions src/components/view/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ViewTree extends Component {
]}
<Tree
items={tree}
textDirection={this.props.editor.locale.contentLanguageDirection}
onClick={this.props.onClick}
showCompactText="true"
activeNode={this.props.currentEditorNode}
Expand Down
1 change: 1 addition & 0 deletions tests/inspector/components/model/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ describe( '<ModelTree />', () => {
expect( tree.props().onClick ).to.equal( clickSpy );
expect( tree.props().showCompactText ).to.be.false;
expect( tree.props().activeNode ).to.be.undefined;
expect( tree.props().textDirection ).to.equal( 'ltr' );
} );

it( 'renders a tree #1', () => {
Expand Down
8 changes: 8 additions & 0 deletions tests/inspector/components/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ describe( '<Tree />', () => {
wrapper.unmount();
} );

it( 'supports text direction', () => {
wrapper = mount( <Tree textDirection="rtl" /> );

expect( wrapper ).to.have.className( 'ck-inspector-tree_text-direction_rtl' );

wrapper.unmount();
} );

describe( 'elements', () => {
let wrapper, itemA, itemAA, itemB, activeNode;

Expand Down
1 change: 1 addition & 0 deletions tests/inspector/components/view/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ describe( '<ViewTree />', () => {
expect( tree.props().onClick ).to.equal( clickSpy );
expect( tree.props().showCompactText ).to.equal( 'true' );
expect( tree.props().activeNode ).to.be.undefined;
expect( tree.props().textDirection ).to.equal( 'ltr' );
} );

it( 'renders empty elements', () => {
Expand Down

0 comments on commit 40c3102

Please sign in to comment.