Skip to content

Commit

Permalink
feat: 🎸 arabic support
Browse files Browse the repository at this point in the history
  • Loading branch information
BaytaX committed Sep 19, 2024
1 parent 0e5bba1 commit 91917d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion packages/affine/block-paragraph/src/paragraph-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export class ParagraphBlockComponent extends CaptionedBlockComponent<
}

override renderBlock(): TemplateResult<1> {
const arabicRegex = /^[\u0600-\u06FF]$/;
const { type$ } = this.model;
const children = html`<div
class="affine-block-children-container"
Expand All @@ -150,7 +151,13 @@ export class ParagraphBlockComponent extends CaptionedBlockComponent<

return html`
<div class="affine-paragraph-block-container">
<div class="affine-paragraph-rich-text-wrapper ${type$.value}">
<div
class="affine-paragraph-rich-text-wrapper ${arabicRegex.test(
this.model.text.yText.toJSON()[0]
)
? 'rtl'
: ''} ${type$.value}"
>
<rich-text
.yText=${this.model.text.yText}
.inlineEventSource=${this.topContenteditableElement ?? nothing}
Expand Down
4 changes: 3 additions & 1 deletion packages/affine/block-paragraph/src/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export const paragraphBlockStyles = css`
.affine-paragraph-rich-text-wrapper {
position: relative;
}
.rtl {
direction: rtl !important;
}
affine-paragraph code {
font-size: calc(var(--affine-font-base) - 3px);
padding: 0px 4px 2px;
Expand Down

0 comments on commit 91917d6

Please sign in to comment.