Added animated auto-opening link modal, custom image node with isolated caption deletion, fixed single-select category data binding, improved featured image layout, and updated README.
48 lines
2.3 KiB
TypeScript
48 lines
2.3 KiB
TypeScript
// تست موقت رندر استاتیک و ابزارها — پس از اجرا حذف میشود
|
|
import { renderToHTMLString } from '@tiptap/static-renderer'
|
|
import { ARTICLE_EXTENSIONS } from './src/components/admin/ArticleEditor'
|
|
import { formatReadingTime, readingTimeMinutes } from './src/utils/readingTime'
|
|
import { buildLinkRel, normalizeHref, parseLinkRel } from './src/utils/link'
|
|
import { docHeadings, docImages, docToText } from './src/utils/tiptapDoc'
|
|
|
|
const doc = {
|
|
type: 'doc',
|
|
content: [
|
|
{ type: 'paragraph', content: [{ type: 'text', text: 'متن نمونه مقاله برای تست رندر' }] },
|
|
{
|
|
type: 'image',
|
|
attrs: { src: '/media/a.jpg', alt: 'تصویر تست', title: 'Photo 1', caption: 'کپشن تصویر تست' },
|
|
},
|
|
{
|
|
type: 'paragraph',
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: 'لینک خارجی',
|
|
marks: [{ type: 'link', attrs: { href: 'https://example.com', target: '_blank', rel: 'noopener noreferrer nofollow' } }],
|
|
},
|
|
],
|
|
},
|
|
{ type: 'heading', attrs: { level: 2 }, content: [{ type: 'text', text: 'تیتر دوم' }] },
|
|
],
|
|
}
|
|
|
|
const html = renderToHTMLString({ extensions: ARTICLE_EXTENSIONS, content: doc as never })
|
|
|
|
console.log('--- rendered html ---')
|
|
console.log(html)
|
|
console.log('--- checks ---')
|
|
console.log('has figure:', html.includes('<figure'))
|
|
console.log('has figcaption:', html.includes('<figcaption') && html.includes('کپشن تصویر تست'))
|
|
console.log('has img src:', html.includes('src="/media/a.jpg"'))
|
|
console.log('has alt:', html.includes('alt="تصویر تست"'))
|
|
console.log('has title:', html.includes('title="Photo 1"'))
|
|
console.log('link rel/target:', html.includes('rel="noopener noreferrer nofollow"'), html.includes('target="_blank"'))
|
|
console.log('--- text utils ---')
|
|
console.log('text:', docToText(doc))
|
|
console.log('h2:', docHeadings(doc, 2), '| images:', docImages(doc).length)
|
|
console.log('reading time:', formatReadingTime(doc), '| minutes:', readingTimeMinutes(doc))
|
|
console.log('--- link helpers ---')
|
|
console.log('normalize:', normalizeHref('example.com'), '|', normalizeHref('/contact'), '|', normalizeHref('javascript:alert(1)'))
|
|
console.log('rel:', buildLinkRel({ newTab: true, nofollow: true }), '|', buildLinkRel({ newTab: false, nofollow: false }), '|', parseLinkRel('noopener noreferrer').newTab)
|