Welcome to mirror list, hosted at ThFree Co, Russian Federation.

heading.js « extensions « content_editor « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 41903162ba52e33d5aedf477314f59de9fa2c82b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { Heading } from '@tiptap/extension-heading';
import { textblockTypeInputRule } from '@tiptap/core';

export default Heading.extend({
  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 },
      });
    });
  },
});