UNPKG

tiptap-extension-line-height

Version:
38 lines (36 loc) 831 B
import { Extension } from "@tiptap/core"; export default Extension.create({ name: "lineHeight", addGlobalAttributes() { return [ { types: ["paragraph"], attributes: { lineHeight: { default: null, parseHTML: (element) => element.style.lineHeight, renderHTML: (attributes) => { if (!attributes.lineHeight) { return {}; } return { style: `line-height: ${attributes.lineHeight}`, }; }, }, }, }, ]; }, addCommands() { return { setLineHeight: (lineHeight) => ({ commands }) => { return commands.updateAttributes("paragraph", { lineHeight, }); }, }; }, });