Files
Momento/memento-note/components/tiptap-clip-article-extension.ts
Antigravity e881004c77
Some checks failed
CI / Lint, Test & Build (push) Failing after 1m7s
CI / Deploy production (on server) (push) Has been skipped
feat(insights): fix DBSCAN, Persian embeddings crash, D3 physics layouts, and D3 node not found runtime error
2026-05-24 18:57:33 +00:00

59 lines
1.3 KiB
TypeScript

import { Node, mergeAttributes } from '@tiptap/core'
/** Conteneur RTL pour articles clippés — préserve direction héritée (listes, paragraphes). */
export const ClipArticleExtension = Node.create({
name: 'clipArticle',
group: 'block',
content: '(block | bulletList | orderedList)+',
defining: true,
addAttributes() {
return {
dir: {
default: 'rtl',
parseHTML: (element) => element.getAttribute('dir') || 'rtl',
renderHTML: (attributes) => {
if (!attributes.dir) return { dir: 'rtl' }
return { dir: attributes.dir }
},
},
lang: {
default: null,
parseHTML: (element) => element.getAttribute('lang'),
renderHTML: (attributes) => {
if (!attributes.lang) return {}
return { lang: attributes.lang }
},
},
}
},
parseHTML() {
return [
{
tag: 'div.clip-article--rtl',
priority: 60,
},
{
tag: 'div.clip-article[dir="rtl"]',
priority: 55,
},
{
tag: 'div[dir="rtl"][class*="clip-article"]',
priority: 50,
},
]
},
renderHTML({ HTMLAttributes }) {
return [
'div',
mergeAttributes(HTMLAttributes, {
class: 'clip-article clip-article--rtl',
dir: 'rtl',
}),
0,
]
},
})