Skip to content

Commit 951cd56

Browse files
committed
fix: add dir=auto to table cells for proper RTL/LTR text direction
1 parent 3696e8f commit 951cd56

1 file changed

Lines changed: 19 additions & 18 deletions

File tree

src/lib/components/chat/Messages/Markdown/MarkdownTokens.svelte

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,22 +132,22 @@
132132
{/if}
133133
{:else if token.type === 'table'}
134134
<div class="relative w-full group mb-2">
135-
<div class="scrollbar-hidden relative overflow-x-auto max-w-full">
135+
<div class="scrollbar-hidden relative overflow-x-auto max-w-full" dir="auto">
136136
<table
137-
class=" w-full text-sm text-left text-gray-500 dark:text-gray-400 max-w-full rounded-xl"
138-
dir="auto"
137+
class=" w-full text-sm text-start text-gray-500 dark:text-gray-400 max-w-full rounded-xl"
139138
>
140139
<thead
141140
class="text-xs text-gray-700 uppercase bg-white dark:bg-gray-900 dark:text-gray-400 border-none"
142141
>
143142
<tr class="">
144143
{#each token.header as header, headerIdx}
145-
<th
146-
scope="col"
147-
class="px-2.5! py-2! cursor-pointer border-b border-gray-100! dark:border-gray-800!"
148-
style={token.align[headerIdx] ? '' : `text-align: ${token.align[headerIdx]}`}
149-
>
150-
<div class="gap-1.5 text-left">
144+
<th
145+
scope="col"
146+
class="px-2.5! py-2! cursor-pointer border-b border-gray-100! dark:border-gray-800!"
147+
style={token.align[headerIdx] ? '' : `text-align: ${token.align[headerIdx]}`}
148+
dir="auto"
149+
>
150+
<div class="gap-1.5 text-start">
151151
<div class="shrink-0 break-normal">
152152
<MarkdownInlineTokens
153153
id={`${id}-${tokenIdx}-header-${headerIdx}`}
@@ -166,15 +166,16 @@
166166
{#each token.rows as row, rowIdx}
167167
<tr class="bg-white dark:bg-gray-900 text-xs">
168168
{#each row ?? [] as cell, cellIdx}
169-
<td
170-
class="px-3! py-2! text-gray-900 dark:text-white w-max {token.rows.length -
171-
1 ===
172-
rowIdx
173-
? ''
174-
: 'border-b border-gray-50! dark:border-gray-850!'}"
175-
style={token.align[cellIdx] ? `text-align: ${token.align[cellIdx]}` : ''}
176-
>
177-
<div class="break-normal">
169+
<td
170+
class="px-3! py-2! text-gray-900 dark:text-white w-max {token.rows.length -
171+
1 ===
172+
rowIdx
173+
? ''
174+
: 'border-b border-gray-50! dark:border-gray-850!'}"
175+
style={token.align[cellIdx] ? `text-align: ${token.align[cellIdx]}` : ''}
176+
dir="auto"
177+
>
178+
<div class="break-normal text-start">
178179
<MarkdownInlineTokens
179180
id={`${id}-${tokenIdx}-row-${rowIdx}-${cellIdx}`}
180181
tokens={cell.tokens}

0 commit comments

Comments
 (0)