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.

23 lines (18 loc) 768 B
// extensions/removeEmptyHeadings.js import { Plugin } from 'prosemirror-state' export const RemoveEmptyHeadings = () => new Plugin({ appendTransaction(trans, oldState, newState) { if (!trans.some(tr => tr.docChanged)) return null const { tr } = newState let modified = false newState.doc.descendants((node, pos) => { if (node.type.name === 'heading' && node.textContent.trim() === '') { // به پاراگرافِ خالی تبدیل کن tr.setNodeMarkup(pos, newState.schema.nodes.paragraph, {}) modified = true } }) return modified ? tr : null }, })