debian-mirror-gitlab/app/assets/javascripts/content_editor/extensions/heading.js
2023-07-09 08:55:56 +05:30

24 lines
582 B
JavaScript

import { Heading } from '@tiptap/extension-heading';
import { textblockTypeInputRule } from '@tiptap/core';
export default Heading.extend({
addOptions() {
return {
...this.parent?.(),
HTMLAttributes: {
dir: 'auto',
},
};
},
addInputRules() {
return this.options.levels.map((level) => {
return textblockTypeInputRule({
// make sure heading regex doesn't conflict with issue references
find: new RegExp(`^(#{1,${level}})[ \t]$`),
type: this.type,
getAttributes: { level },
});
});
},
});