fix(blog): لینک کپشن رندر عمومی را میکراند (اسپرد اسپک) + نوار ابزار با جابهجایی کرسر آپدیت شود + صفحهٔ ادیتور انگلیسی LTR
This commit is contained in:
@@ -342,6 +342,15 @@ export function ArticleWritePage() {
|
|||||||
// در زبان انگلیسی، فیلدهای متنی به ستونهای _en میروند؛ اسلاگ/تصویر/وضعیت مشترکاند
|
// در زبان انگلیسی، فیلدهای متنی به ستونهای _en میروند؛ اسلاگ/تصویر/وضعیت مشترکاند
|
||||||
const suf = <N extends string>(name: N) => `${name}${editLang === 'en' ? '_en' : ''}` as keyof Draft
|
const suf = <N extends string>(name: N) => `${name}${editLang === 'en' ? '_en' : ''}` as keyof Draft
|
||||||
// مقدار فعال فیلد دوزبانه — برای value ورودیها و چکلیست سئو
|
// مقدار فعال فیلد دوزبانه — برای 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 =>
|
const activeVal = (name: 'title' | 'slug' | 'author' | 'seo_keyphrase' | 'meta_description' | 'excerpt'): string =>
|
||||||
String((editLang === 'en' ? draft[`${name}_en` as keyof Draft] : draft[name]) ?? '')
|
String((editLang === 'en' ? draft[`${name}_en` as keyof Draft] : draft[name]) ?? '')
|
||||||
|
|
||||||
@@ -351,7 +360,7 @@ export function ArticleWritePage() {
|
|||||||
.join(' - ')
|
.join(' - ')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div dir="rtl" className="min-h-screen bg-ink font-pinar text-ivory">
|
<div dir={editLang === 'en' ? 'ltr' : 'rtl'} className="min-h-screen bg-ink font-pinar text-ivory">
|
||||||
{/* نوار بالا */}
|
{/* نوار بالا */}
|
||||||
<header className="sticky top-0 z-40 border-b border-ivory/10 bg-ink/95 backdrop-blur-md">
|
<header className="sticky top-0 z-40 border-b border-ivory/10 bg-ink/95 backdrop-blur-md">
|
||||||
<div className="mx-auto flex max-w-4xl items-center justify-between gap-4 px-6 py-3">
|
<div className="mx-auto flex max-w-4xl items-center justify-between gap-4 px-6 py-3">
|
||||||
|
|||||||
@@ -199,10 +199,13 @@ export function ArticleEditor({ doc, onChange, contentKey }: ArticleEditorProps)
|
|||||||
extensions: ARTICLE_EXTENSIONS,
|
extensions: ARTICLE_EXTENSIONS,
|
||||||
content: doc && Object.keys(doc).length ? doc : undefined,
|
content: doc && Object.keys(doc).length ? doc : undefined,
|
||||||
immediatelyRender: false,
|
immediatelyRender: false,
|
||||||
|
// نوار ابزار فقط با رندر دوباره روی هر تراکنش زنده میماند (پیشفرض v3 خاموش است)
|
||||||
|
shouldRerenderOnTransaction: true,
|
||||||
editorProps: {
|
editorProps: {
|
||||||
attributes: {
|
attributes: {
|
||||||
dir: 'rtl',
|
dir: 'rtl',
|
||||||
lang: 'fa',
|
lang: 'fa',
|
||||||
|
'data-base-dir': 'rtl',
|
||||||
class: 'article-body min-h-[300px] px-4 py-4 focus:outline-none',
|
class: 'article-body min-h-[300px] px-4 py-4 focus:outline-none',
|
||||||
'data-wysiwyg': 'true',
|
'data-wysiwyg': 'true',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -59,19 +59,17 @@ export const ArticleImage = Image.extend({
|
|||||||
|
|
||||||
// کپشن خالی → عنصر figcaption اصلاً رندر نمیشود (فقط تصویر میماند)
|
// کپشن خالی → عنصر figcaption اصلاً رندر نمیشود (فقط تصویر میماند)
|
||||||
const captionHref = (HTMLAttributes.caption_href as string | undefined)?.trim() ?? ''
|
const captionHref = (HTMLAttributes.caption_href as string | undefined)?.trim() ?? ''
|
||||||
const figcaption: Array<string | Record<string, unknown>> = captionHref
|
// توجه: آرایهٔ درونی بهصورت تو در تو پاس میشود — اسپرد آن اسپک را تخت میکند
|
||||||
? [
|
// و رندرر استاتیک با «Unsupported DomOutputSpec» میمیرد.
|
||||||
'a',
|
const captionSpec = captionHref
|
||||||
{ href: captionHref, target: '_blank', rel: 'noopener noreferrer nofollow' },
|
? ['a', { href: captionHref, target: '_blank', rel: 'noopener noreferrer nofollow' }, caption]
|
||||||
caption,
|
: caption
|
||||||
]
|
|
||||||
: [caption]
|
|
||||||
return caption
|
return caption
|
||||||
? [
|
? [
|
||||||
'figure',
|
'figure',
|
||||||
{ class: 'article-figure' },
|
{ class: 'article-figure' },
|
||||||
image,
|
image,
|
||||||
['figcaption', { class: 'article-figure__caption' }, ...figcaption],
|
['figcaption', { class: 'article-figure__caption' }, captionSpec],
|
||||||
]
|
]
|
||||||
: ['figure', { class: 'article-figure' }, image]
|
: ['figure', { class: 'article-figure' }, image]
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user