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

description_term.js « nodes « markdown « behaviors « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 89057ec64443a1d43c438286dda69ac57a3b93f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* eslint-disable class-methods-use-this */

import { Node } from 'tiptap';

// Transforms generated HTML back to GFM for Banzai::Filter::MarkdownFilter
export default class DescriptionTerm extends Node {
  get name() {
    return 'description_term';
  }

  get schema() {
    return {
      content: 'text*',
      marks: '',
      defining: true,
      parseDOM: [{ tag: 'dt' }],
      toDOM: () => ['dt', 0],
    };
  }

  toMarkdown(state, node) {
    state.flushClose(state.closed && state.closed.type === node.type ? 1 : 2);
    state.write('<dt>');
    state.text(node.textContent, false);
    state.write('</dt>');
    state.closeBlock(node);
  }
}