Skip to content

Commit 5f013ce

Browse files
committed
fix: add text direction support to input fields
Set dir on TipTap block nodes (paragraph, heading, blockquote) and on message edit textareas using the chatDirection setting.
1 parent 547c587 commit 5f013ce

5 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/lib/components/channel/MessageInput.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@
871871
{#key $settings?.richTextInput && $settings?.showFormattingToolbar}
872872
<RichTextInput
873873
id="chat-input"
874+
dir={$settings?.chatDirection ?? 'auto'}
874875
bind:this={chatInputElement}
875876
json={true}
876877
messageInput={true}

src/lib/components/chat/MessageInput.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,7 @@
13051305
<RichTextInput
13061306
bind:this={chatInputElement}
13071307
id="chat-input"
1308+
dir={$settings?.chatDirection ?? 'auto'}
13081309
editable={!showInputModal}
13091310
onChange={(content) => {
13101311
prompt = content.md;

src/lib/components/chat/Messages/ResponseMessage.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@
694694
<textarea
695695
id="message-edit-{message.id}"
696696
bind:this={editTextAreaElement}
697+
dir={$settings?.chatDirection ?? 'auto'}
697698
class=" bg-transparent outline-hidden w-full resize-none"
698699
bind:value={editedContent}
699700
on:input={(e) => {

src/lib/components/chat/Messages/UserMessage.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@
287287
<textarea
288288
id="message-edit-{message.id}"
289289
bind:this={messageEditTextAreaElement}
290+
dir={$settings?.chatDirection ?? 'auto'}
290291
class=" bg-transparent outline-hidden w-full resize-none"
291292
bind:value={editedContent}
292293
on:input={(e) => {

src/lib/components/common/RichTextInput.svelte

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
export let documentId = '';
171171
172172
export let className = 'input-prose min-h-fit h-full';
173+
export let dir = 'auto';
173174
export let placeholder = $i18n.t('Type here...');
174175
let _placeholder = placeholder;
175176
@@ -691,7 +692,10 @@
691692
element: element,
692693
extensions: [
693694
StarterKit.configure({
694-
link: link
695+
link: link,
696+
paragraph: { HTMLAttributes: { dir } },
697+
heading: { HTMLAttributes: { dir } },
698+
blockquote: { HTMLAttributes: { dir } }
695699
}),
696700
...(dragHandle ? [ListItemDragHandle] : []),
697701
Placeholder.configure({ placeholder: () => _placeholder, showOnlyWhenEditable: false }),
@@ -855,7 +859,7 @@
855859
}
856860
},
857861
editorProps: {
858-
attributes: { id },
862+
attributes: { id, dir },
859863
handlePaste: (view, event) => {
860864
// Force plain-text pasting when richText === false
861865
if (!richText) {
@@ -1179,6 +1183,6 @@
11791183

11801184
<div
11811185
bind:this={element}
1182-
dir="auto"
1186+
{dir}
11831187
class="relative w-full min-w-full {className} {!editable ? 'cursor-not-allowed' : ''}"
11841188
/>

0 commit comments

Comments
 (0)