diff --git a/frontend/src/admin/ArticleWritePage.tsx b/frontend/src/admin/ArticleWritePage.tsx index f02cecd..b6874d4 100644 --- a/frontend/src/admin/ArticleWritePage.tsx +++ b/frontend/src/admin/ArticleWritePage.tsx @@ -342,6 +342,15 @@ export function ArticleWritePage() { // در زبان انگلیسی، فیلدهای متنی به ستون‌های _en می‌روند؛ اسلاگ/تصویر/وضعیت مشترک‌اند const suf = (name: N) => `${name}${editLang === 'en' ? '_en' : ''}` as keyof Draft // مقدار فعال فیلد دوزبانه — برای value ورودی‌ها و چک‌لیست سئو + // جهت ویرایشگر محتوایی با زبان ویرایش همگام می‌شود — صفحهٔ انگلیسی LTR بماند + useEffect(() => { + const el = document.querySelector('.article-body[data-wysiwyg="true"]') + if (el) { + el.setAttribute('dir', editLang === 'en' ? 'ltr' : 'rtl') + el.setAttribute('lang', editLang) + } + }, [editLang, createdId]) + const activeVal = (name: 'title' | 'slug' | 'author' | 'seo_keyphrase' | 'meta_description' | 'excerpt'): string => String((editLang === 'en' ? draft[`${name}_en` as keyof Draft] : draft[name]) ?? '') @@ -351,7 +360,7 @@ export function ArticleWritePage() { .join(' - ') return ( -
+
{/* نوار بالا */}
diff --git a/frontend/src/components/admin/ArticleEditor.tsx b/frontend/src/components/admin/ArticleEditor.tsx index bdb3847..aa30ec0 100644 --- a/frontend/src/components/admin/ArticleEditor.tsx +++ b/frontend/src/components/admin/ArticleEditor.tsx @@ -199,10 +199,13 @@ export function ArticleEditor({ doc, onChange, contentKey }: ArticleEditorProps) extensions: ARTICLE_EXTENSIONS, content: doc && Object.keys(doc).length ? doc : undefined, immediatelyRender: false, + // نوار ابزار فقط با رندر دوباره روی هر تراکنش زنده می‌ماند (پیش‌فرض v3 خاموش است) + shouldRerenderOnTransaction: true, editorProps: { attributes: { dir: 'rtl', lang: 'fa', + 'data-base-dir': 'rtl', class: 'article-body min-h-[300px] px-4 py-4 focus:outline-none', 'data-wysiwyg': 'true', }, diff --git a/frontend/src/components/admin/ArticleImage.ts b/frontend/src/components/admin/ArticleImage.ts index 6ab05de..b6b1c71 100644 --- a/frontend/src/components/admin/ArticleImage.ts +++ b/frontend/src/components/admin/ArticleImage.ts @@ -59,19 +59,17 @@ export const ArticleImage = Image.extend({ // کپشن خالی → عنصر figcaption اصلاً رندر نمی‌شود (فقط تصویر می‌ماند) const captionHref = (HTMLAttributes.caption_href as string | undefined)?.trim() ?? '' - const figcaption: Array> = captionHref - ? [ - 'a', - { href: captionHref, target: '_blank', rel: 'noopener noreferrer nofollow' }, - caption, - ] - : [caption] + // توجه: آرایهٔ درونی به‌صورت تو در تو پاس می‌شود — اسپرد آن اسپک را تخت می‌کند + // و رندرر استاتیک با «Unsupported DomOutputSpec» می‌میرد. + const captionSpec = captionHref + ? ['a', { href: captionHref, target: '_blank', rel: 'noopener noreferrer nofollow' }, caption] + : caption return caption ? [ 'figure', { class: 'article-figure' }, image, - ['figcaption', { class: 'article-figure__caption' }, ...figcaption], + ['figcaption', { class: 'article-figure__caption' }, captionSpec], ] : ['figure', { class: 'article-figure' }, image] },