Skip to content

Commit 3281abd

Browse files
committed
fix: add dir=auto to table cells for proper RTL/LTR text direction
1 parent 83cc083 commit 3281abd

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,21 @@
134134
<div class="relative w-full group mb-2">
135135
<div class="scrollbar-hidden relative overflow-x-auto max-w-full">
136136
<table
137-
class=" w-full text-sm text-left text-gray-500 dark:text-gray-400 max-w-full rounded-xl"
137+
class=" w-full text-sm text-start text-gray-500 dark:text-gray-400 max-w-full rounded-xl"
138138
dir="auto"
139139
>
140140
<thead
141141
class="text-xs text-gray-700 uppercase bg-white dark:bg-gray-900 dark:text-gray-400 border-none"
142142
>
143143
<tr class="">
144144
{#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">
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+
dir="auto"
150+
>
151+
<div class="gap-1.5 text-start">
151152
<div class="shrink-0 break-normal">
152153
<MarkdownInlineTokens
153154
id={`${id}-${tokenIdx}-header-${headerIdx}`}
@@ -166,15 +167,16 @@
166167
{#each token.rows as row, rowIdx}
167168
<tr class="bg-white dark:bg-gray-900 text-xs">
168169
{#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">
170+
<td
171+
class="px-3! py-2! text-gray-900 dark:text-white w-max {token.rows.length -
172+
1 ===
173+
rowIdx
174+
? ''
175+
: 'border-b border-gray-50! dark:border-gray-850!'}"
176+
style={token.align[cellIdx] ? `text-align: ${token.align[cellIdx]}` : ''}
177+
dir="auto"
178+
>
179+
<div class="break-normal text-start">
178180
<MarkdownInlineTokens
179181
id={`${id}-${tokenIdx}-row-${rowIdx}-${cellIdx}`}
180182
tokens={cell.tokens}

0 commit comments

Comments
 (0)