Skip to content

Commit

Permalink
rtl in chat form
Browse files Browse the repository at this point in the history
  • Loading branch information
ra3orblade committed Nov 15, 2024
1 parent 69d6335 commit 81e4aaa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/scss/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ select:-webkit-autofill:hover,
select:-webkit-autofill:focus { transition: background-color 5000s ease-in-out 0s; }
input, textarea, select { font-family: 'Inter'; }


#drag { -webkit-app-region: drag; position: fixed; top: 0px; left: 0px; width: 100%; height: 52px; z-index: -1; user-select: none; pointer-events: all; }
#root-loader { position: fixed; width: 100%; height: 100%; left: 0px; top: 0px; background: #060606; z-index: 1000; transition: opacity 0.3s ease-in-out; }
#root-loader {
Expand Down Expand Up @@ -106,6 +107,7 @@ html.platformWindows, html.platformLinux {
::-webkit-input-placeholder { color: var(--color-text-tertiary) !important; }
.isBlurred { filter: blur(7px); }
.animationWord { display: inline-block; }
.isRtl { direction: rtl; text-align: right; }

.fileWrap { position: relative; overflow: hidden; }
.fileWrap {
Expand Down
11 changes: 11 additions & 0 deletions src/ts/component/block/chat/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const ChatForm = observer(class ChatForm extends React.Component<Props, State> {
this.onBlurInput = this.onBlurInput.bind(this);
this.onKeyUpInput = this.onKeyUpInput.bind(this);
this.onKeyDownInput = this.onKeyDownInput.bind(this);
this.onInput = this.onInput.bind(this);
this.onPaste = this.onPaste.bind(this);
this.onMention = this.onMention.bind(this);
this.onChatButtonSelect = this.onChatButtonSelect.bind(this);
Expand Down Expand Up @@ -155,6 +156,7 @@ const ChatForm = observer(class ChatForm extends React.Component<Props, State> {
onBlur={this.onBlurInput}
onKeyUp={this.onKeyUpInput}
onKeyDown={this.onKeyDownInput}
onInput={this.onInput}
onPaste={this.onPaste}
onMouseDown={this.onMouseDown}
onMouseUp={this.onMouseUp}
Expand Down Expand Up @@ -438,6 +440,13 @@ const ChatForm = observer(class ChatForm extends React.Component<Props, State> {
this.removeBookmarks();
};

onInput () {
const value = this.getTextValue();
const checkRtl = U.Common.checkRtl(value);

$(this.refEditable?.node).toggleClass('isRtl', checkRtl);
};

onPaste (e: any) {
e.preventDefault();

Expand Down Expand Up @@ -484,6 +493,8 @@ const ChatForm = observer(class ChatForm extends React.Component<Props, State> {
if (list.length) {
this.addAttachments(list);
};

this.onInput();
};

canDrop (e: any): boolean {
Expand Down
4 changes: 4 additions & 0 deletions src/ts/lib/util/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,10 @@ class UtilCommon {
//return this.isAlphaVersion() || this.isBetaVersion() || !this.getElectron().isPackaged;
};

checkRtl (s: string): boolean {
return /^[\u04c7-\u0591\u05D0-\u05EA\u05F0-\u05F4\u0600-\u06FF]/.test(s);
};

};

export default new UtilCommon();

0 comments on commit 81e4aaa

Please sign in to comment.