mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-01-20 20:01:18 +00:00
18 lines
499 B
TypeScript
18 lines
499 B
TypeScript
/* eslint-disable security/detect-non-literal-regexp */
|
|
import { textblockTypeInputRule } from '@tiptap/core'
|
|
import { Heading } from '@tiptap/extension-heading'
|
|
|
|
export const CustomHeading = Heading.extend({
|
|
addInputRules() {
|
|
return this.options.levels.map((level) => {
|
|
return textblockTypeInputRule({
|
|
find: new RegExp(`^(#{${Math.min(...this.options.levels)},${level}}) $`),
|
|
type: this.type,
|
|
getAttributes: {
|
|
level,
|
|
},
|
|
})
|
|
})
|
|
},
|
|
})
|