Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/arabic support #8422

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/affine/block-list/src/list-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ export class ListBlockComponent extends CaptionedBlockComponent<

override renderBlock(): TemplateResult<1> {
const { model, _onClickIcon } = this;
const arabicRegex = /^[\u0600-\u06FF]$/;

const collapsed = this.doc.readonly
? this._isCollapsedWhenReadOnly
: !!model.collapsed;
Expand All @@ -183,8 +185,12 @@ export class ListBlockComponent extends CaptionedBlockComponent<
</div>`;

return html`
<div class=${'affine-list-block-container'}>
<div class=${`affine-list-rich-text-wrapper ${checked}`}>
<div class=${'affine-list-block-container '}>
<div
class=${`affine-list-rich-text-wrapper ${
arabicRegex.test(this.model.text.yText.toJSON()[0]) ? `rtl` : ''
} ${checked}`}
>
${this._toggleTemplate(collapsed)} ${listIcon}
<rich-text
.yText=${this.model.text.yText}
Expand Down
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 === 'quote' ? `${type$.value}-ar` : type$.value}`
: ` ${type$.value}`} "
>
<rich-text
.yText=${this.model.text.yText}
.inlineEventSource=${this.topContenteditableElement ?? nothing}
Expand Down
27 changes: 25 additions & 2 deletions 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 Expand Up @@ -104,7 +106,7 @@ export const paragraphBlockStyles = css`

.quote {
line-height: 26px;
padding-left: 17px;
padding-left: 17px !important;
margin-top: var(--affine-paragraph-space);
padding-top: 10px;
padding-bottom: 10px;
Expand All @@ -123,6 +125,27 @@ export const paragraphBlockStyles = css`
border-radius: 18px;
}

.quote-ar {
line-height: 26px;
padding-right: 17px !important;
margin-top: var(--affine-paragraph-space);
padding-top: 10px;
padding-bottom: 10px;
position: relative;
}
.quote-ar::after {
content: '';
width: 2px;
height: calc(100% - 20px);
margin-top: 10px;
margin-bottom: 10px;
position: absolute;
right: 0;
top: 0;
background: var(--affine-quote-color);
border-radius: 18px;
}

.affine-paragraph-placeholder {
position: absolute;
display: none;
Expand Down
Loading