UNPKG

nilfam-editor

Version:

A powerful, customizable rich-text editor built with TipTap, React, and Tailwind CSS. Supports RTL/LTR text, resizable media (images/videos), tables, code blocks, font styling, and more for an enhanced content creation experience.

20 lines (16 loc) 520 B
// utils/getHeadings.js export function getHeadings(editor) { const headings = [] // اگر ادیتور یا state وجود نداشت، خالی برگرد if (!editor?.state?.doc) return headings editor.state.doc.descendants((node) => { if (node.type.name === 'heading') { headings.push({ level: node.attrs.level, id: node.attrs.id, text: node.textContent, }) } }) return headings }