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.

35 lines (33 loc) 1.04 kB
import {Extension} from "@tiptap/core"; export const FontFamily = Extension.create({ name: 'fontFamily', addOptions() { return { types: ['textStyle'], }; }, addGlobalAttributes() { return [ { types: this.options.types, attributes: { fontFamily: { default: null, parseHTML: (element) => element.style.fontFamily || null, renderHTML: (attributes) => { if (!attributes.fontFamily) return {}; return { style: `font-family: ${attributes.fontFamily};` }; }, }, }, }, ]; }, addCommands() { return { setFontFamily: (fontFamily) => ({ chain }) => { return chain().setMark('textStyle', { fontFamily }).run(); }, }; }, });