debian-mirror-gitlab/app/assets/javascripts/content_editor/extensions/frontmatter.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
963 B
JavaScript
Raw Normal View History

2022-08-27 11:52:29 +05:30
import { lowlight } from 'lowlight/lib/core';
2021-11-18 22:05:49 +05:30
import { PARSE_HTML_PRIORITY_HIGHEST } from '../constants';
import CodeBlockHighlight from './code_block_highlight';
export default CodeBlockHighlight.extend({
name: 'frontmatter',
2022-07-16 23:28:13 +05:30
2022-08-27 11:52:29 +05:30
addOptions() {
return {
lowlight,
};
},
2022-07-16 23:28:13 +05:30
addAttributes() {
return {
...this.parent?.(),
isFrontmatter: {
default: true,
},
};
},
2021-11-18 22:05:49 +05:30
parseHTML() {
return [
{
tag: 'pre[data-lang-params="frontmatter"]',
preserveWhitespace: 'full',
priority: PARSE_HTML_PRIORITY_HIGHEST,
},
];
},
2022-03-02 08:16:31 +05:30
addCommands() {
return {
setFrontmatter: (attributes) => ({ commands }) => {
return commands.setNode(this.name, attributes);
},
toggleFrontmatter: (attributes) => ({ commands }) => {
return commands.toggleNode(this.name, 'paragraph', attributes);
},
};
},
2021-12-11 22:18:48 +05:30
addInputRules() {
return [];
},
2021-11-18 22:05:49 +05:30
});