Total Complexity | 3 |
Complexity/F | 1.5 |
Lines of Code | 53 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /* |
||
20 | import { Plugin } from 'ckeditor5/src/core'; |
||
21 | import GFMDataProcessor from '@ckeditor/ckeditor5-markdown-gfm/src/gfmdataprocessor'; |
||
22 | |||
23 | const ALLOWED_TAGS = [ |
||
24 | //Common elements |
||
25 | 'sup', |
||
26 | 'sub', |
||
27 | 'u', |
||
28 | 'kbd', |
||
29 | 'mark', |
||
30 | 'ins', |
||
31 | 'small', |
||
32 | 'abbr', |
||
33 | 'br', |
||
34 | |||
35 | //Block elements |
||
36 | 'span', |
||
37 | 'p', |
||
38 | 'img', |
||
39 | |||
40 | |||
41 | |||
42 | //These commands are somehow ignored: TODO |
||
43 | 'left', |
||
44 | 'center', |
||
45 | 'right', |
||
46 | ]; |
||
47 | |||
48 | /** |
||
49 | * The GitHub Flavored Markdown (GFM) plugin with added HTML tags, which are kept in the output. (inline mode) |
||
50 | * |
||
51 | */ |
||
52 | export default class ExtendedMarkdown extends Plugin { |
||
53 | |||
54 | /** |
||
55 | * @inheritDoc |
||
56 | */ |
||
57 | constructor( editor ) { |
||
58 | super( editor ); |
||
59 | |||
60 | editor.data.processor = new GFMDataProcessor( editor.data.viewDocument ); |
||
61 | for (const tag of ALLOWED_TAGS) { |
||
62 | editor.data.processor.keepHtml(tag); |
||
63 | } |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @inheritDoc |
||
68 | */ |
||
69 | static get pluginName() { |
||
70 | return 'Markdown'; |
||
71 | } |
||
72 | } |
||
73 |