-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added rtl toggle button #3282
Added rtl toggle button #3282
Conversation
browser/components/CodeEditor.js
Outdated
@@ -294,6 +294,8 @@ export default class CodeEditor extends React.Component { | |||
scrollPastEnd: this.props.scrollPastEnd, | |||
inputStyle: 'textarea', | |||
dragDrop: false, | |||
direction: RTL ? 'rtl' : 'ltr', | |||
rtlMoveVisually: RTL ? 'true' : 'false', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you just write RTL
instead of RTL ? 'true' : 'false'
browser/components/CodeEditor.js
Outdated
@@ -555,6 +557,10 @@ export default class CodeEditor extends React.Component { | |||
if (prevProps.keyMap !== this.props.keyMap) { | |||
needRefresh = true | |||
} | |||
if (prevProps.RTL !== this.props.RTL) { | |||
this.editor.setOption('direction', this.props.RTL ? 'rtl' : 'ltr') | |||
this.editor.setOption('rtlMoveVisually', this.props.RTL ? 'true' : 'false') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write this.props.RTL
instead of this.props.RTL ? 'true' : 'false'
please?
${RTL ? 'direction: rtl;' : ''} | ||
${RTL ? 'text-align: right;' : ''} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove these 2 empty lines
onClick, editorDirection | ||
}) => ( | ||
<div styleName='control-toggleModeButton'> | ||
<div styleName={editorDirection ? 'active' : undefined} onClick={() => onClick()}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
editorDirection
is quite hard to understand, can you assign it to a more meaningful variable name such as isRTL
or something?
@ibraude ping! |
@ZeroX-DG Sorry for the delay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
@ibraude can you fix the conflict before I officially approve it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late response. I found some bug when I test it again, can you fix it please?
${scrollPastEnd ? ` | ||
padding-bottom: 90vh; | ||
box-sizing: border-box; | ||
` | ||
: ''} | ||
${optimizeOverflowScroll ? 'height: 100%;' : ''} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This optimizeOverflowScroll
variable is undefined can you fix it please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, very cool 🎉
Description
I have added a direction toggle switch for the MarkdownPreview and CodeEditor. (It's located at the top right, next to the Toggle Mode switch button)
This is so notes can be taken and read comfortably when using right-to-left languages like Hebrew or Arabic.
Here is the Boostnote welcome page in the LTR direction:
Here is the Boostnote welcome page in Hebrew with the RTL direction:
I have also added a hotkey for direction toggle:
Issue fixed
This fixes the open issue "Please add RTL support" #846
I believe this is a simple solution that answers the need for people using both ltr and rtl languages regularly.
Type of changes
Checklist:
All tests pass except for the test:
tests/lib/markdown-toc-generator-test.js
I think that the test throws an error because it recognizes the difference between the rtl to ltr as seen in the image below when infact it is the desired result.
Hope this helps.
Cheers